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.
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.
I understand your concern regarding Cloud Run in smk not recording application logs, whereas prj-cross operates correctly.
Here are my analyses and recommendations: :
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.
Make sure logs are visible and not obscured by filtering in Logs Explorer.
Verify that the Cloud Logging API is activated/enabled and that permissions are appropriately configured.
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.
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.
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?