You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
I have a web api deployed with docker image on GCP GCE. However failed to output any log to stackdriver logging under the tag which my VM stands for.
Most importantly, the same api deployed in my dev env (IDC) can sent log to GCP stackdriver logging successfully, which can be seen in stackdriver logging under the tag 'global'. Of course, with GOOGLE_APPLICATION_CREDENTIALS included.
Environment details
Python 3.6.7
ubuntu 18.04
Cloud API access scopes: Allow full access to all Cloud APIs
The code locates in a file mylogging.py, which will be imported at the start of my flask app.
An easy way to test if my app is able to log onto stackdriver logging.
From above, it seems like the code is functional or log shouldn't be shown as the format i designed. And it looks like some log was sent to gcp with status code as 200. But there is still no log shown in the stackdriver logging under the tag "GCE VM instance 'my instance name'".
How come it can be done in machine outside GCE, like my local machine, but not on GCE.
Sorry I didn't notice that you told me to check stackdriver logging under the tag 'global/cloud'. The log sure did show up under this tag. Thank you so much.
I was always looking under the tag "GCE VM instance 'my instance name'", which was linked directly from the GCE GUI.
Is there any way to direct the log to stackdriver logging "GCE VM instance 'my instance name'"? Which is more straightforward.
Hi @mnguyen25 , sorry that I don't have breakthrough for this, cause I changed to using AWS from this May due to my job changed. Thanks for asking. Would also be glad to know if someone figure it out.
Activity
[-]cannot output GCE (python api) log to stackdriver logging[/-][+]Logging: cannot log on GCE[/+]timfanda35 commentedon Apr 18, 2019
You can try to set the log level.
I write a sample code to reproduce the problem:
Uncomment the
# logger.setLevel(logging.INFO), and execute sample code.You should see the logs in Stackdriver Logging
global/cloudafter seconds.Reference:
https://googleapis.github.io/google-cloud-python/latest/logging/usage.html#cloud-logging-handler
Lance0404 commentedon Apr 23, 2019
Hi @timfanda35 ,
Thank you so much for the fast reply and really sorry for my delayed response. I have modified my code in your way as:
However, yet to succeed.
The code locates in a file mylogging.py, which will be imported at the start of my flask app.
An easy way to test if my app is able to log onto stackdriver logging.
output message as below:
From above, it seems like the code is functional or log shouldn't be shown as the format i designed. And it looks like some log was sent to gcp with status code as 200. But there is still no log shown in the stackdriver logging under the tag "GCE VM instance 'my instance name'".
How come it can be done in machine outside GCE, like my local machine, but not on GCE.
Thank you for the help.
Lance0404 commentedon Apr 23, 2019
Hi @timfanda35 ,
Sorry I didn't notice that you told me to check stackdriver logging under the tag 'global/cloud'. The log sure did show up under this tag. Thank you so much.
I was always looking under the tag "GCE VM instance 'my instance name'", which was linked directly from the GCE GUI.
Is there any way to direct the log to stackdriver logging "GCE VM instance 'my instance name'"? Which is more straightforward.
Thank you for the help.
mnguyen25 commentedon Aug 12, 2019
Hi @Lance0404, is there any update on this?
Lance0404 commentedon Aug 12, 2019
Hi @mnguyen25 , sorry that I don't have breakthrough for this, cause I changed to using AWS from this May due to my job changed. Thanks for asking. Would also be glad to know if someone figure it out.
mnguyen25 commentedon Aug 12, 2019
@Lance0404, lately today, I figured it out, still don't know how to distinguish between cloud env and local env however
This will fail locally cause the request would hang there and fail eventually.
daniel-sanche commentedon Mar 5, 2021
This should be fixed after #200. You will see it in the next release