Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud run no logging

Hi, 

We have the following problem, we have 2 projects
prj-cross and smk, in the prj-cross project the containers write to the log without problems, but in smk they don't log anything, only the gcp log. In both projects the service accounts have the same permissions, but we can't understand why in the smk project it doesn't write to the log.

nortiz_0-1737986427611.png

Best regards

 

1 7 778
7 REPLIES 7

Also the application is in nodejs and uses console.log for logging.
The cloud run service accounts and the account that deploys the container in cloud run have roles/logging.logWriter and roles/logging.viewer.

Hi @nortiz,

Welcome to Google Cloud Community!

I understand your concern regarding Cloud Run in smk not recording application logs, whereas prj-cross operates correctly. 

Here are my analyses and recommendations: :

  1. Cloud Run records logs from console.log only when they are directed to stdout/stderr. You can (re)visit this documentation to know about properly writing container logs for your Cloud Run service or job.

  2. Make sure logs are visible and not obscured by filtering in Logs Explorer.

  3. Verify that the Cloud Logging API is activated/enabled and that permissions are appropriately configured.

  4. Check the Cloud Run setup in both projects to identify any discrepancies. For instance, check if your Node.js application properly writes logs to stdout or stderr:

           console.log("This is an info log");
          console.error("This is an error log");
          You can also test out Cloud Logging API for your Node.js app.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

Hi,

Thank you for your response.

We checked the configuration and everything looks in order compared to both projects.

Also we are using the same docker image, only in the prj-cross project it does show the log and in SMK it does not.

The cloud run service accounts and the service account that deploys the container in cloud run have roles/logging.logWriter and roles/logging.viewer.

That's why we don't understand why we don't see the logs of the containers.

Best regards

it is not working for me.... I have a simple hello world... in other GCP accounts the service prints fine.. In this particular project it stopped working. It worked for a couple of years but suddenly it is not printing anything. I have 15 services running on Cloud Run... All of them stopped printing a couple of months ago.

Does the logging work when you use it locally with Docker?

Hi,

Yes, it works on docker local machine

The only other thing that I see happening is sink filters in the Log Router that might be redirecting logs away from Cloud Logging. Can you check those?