Search code examples
node.jsgoogle-cloud-platformwinstongoogle-cloud-logging

@google-cloud/logging-winston Express middleware request bundling issue


I am using the @google-cloud/logging-winston package in my Node/Express application for logging within Google Cloud Run. Recently I switched to using the Express middleware based logger by using the makeMiddleware() method. I made the switch in order to enable request log bundling. This is now working, but for some reason the logs show up twice in Google Cloud Logging, once as part of the request and again as separate logs.

Is this normal?

Is there any way to skip the extra logging so that any request specific logs only show up under their request?

Update
I am using v4.0.4 of @google-cloud/logging-winston package and v3.3.3 of the winston package.


Solution

  • According to github this is working as intended:

    According to our backend team, this particular case is actually working as intended. We will not resolve this at the API/client library level.

    It is annoying that the logs show up twice in the Logs Viewer UI. So, internally there's now a P2 ticket for a UI improvement on this. Thanks for alerting us on it!

    In the meantime, the recommended approach is still to filter for the *_req lognames while using the UI.

    You can also try updating Winston to latest version and double-checking your transport declaration.