express icon indicating copy to clipboard operation
express copied to clipboard

EXPRESS logs on GCP stackdriver

Open sharmankita opened this issue 1 year ago • 6 comments

Hi ,

Can anyone please help me with this , there is DEBUG flag enabled in my node API set as express* which i guess is printed below errors, But can someone please explain why they are getting marked as error, and if there is any error what is that how can I fix it.

please find the images for reference. WhatsApp Image 2022-05-28 at 2 21 14 PM WhatsApp Image 2022-05-28 at 2 23 53 PM

sharmankita avatar May 28 '22 08:05 sharmankita

@sharmankita what exactly is the issue that you are facing?

Is your code working fine locally? Are there error logs for the same?

aravindvnair99 avatar May 28 '22 10:05 aravindvnair99

@aravindvnair99 Nope not getting errors on local, When I enable debug mode on local it is showing me same logs normally in colors. but IDK why it is printing it in stack driver as error.

sharmankita avatar May 29 '22 09:05 sharmankita

Can anyone please help me with this?

sharmankita avatar Jun 06 '22 09:06 sharmankita

Are you sure you sure not logging to stderr? I have a similar issue with logging from Go binaries and I think Google Logging falls back to error log level when it's unable decipher what the level is. Maybe structured logging helps in this case

(Great profile picture :))

weyert avatar Jun 21 '22 15:06 weyert

Are you sure you sure not logging to stderr? I have a similar issue with logging from Go binaries and I think Google Logging falls back to error log level when it's unable decipher what the level is. Maybe structured logging helps in this case

(Great profile picture :))

I am not logging anything manually.. When I enable debug logs express is printing logs like below screenshot. Screenshot 2022-06-23 at 4 29 58 PM

Thanks :) @weyert

sharmankita avatar Jun 23 '22 11:06 sharmankita

I understand but can you check the labels in Google Logging for one of the log entries whether you don't have something like this in labels the value logName: "projects/my-project/logs/stderr". That would mean it picked it up the messages from the stderr stream which are alway marked as errors.

If not, you might want to consider structured logging to make sure Google Logging picks up the correct log level. I have to admit I wouldn't know how to that for the debug-package, though. This is one of my personal pain peeves with Google Logging

weyert avatar Jun 27 '22 22:06 weyert