Search code examples
pythongoogle-kubernetes-enginestackdrivergoogle-cloud-logging

Logs written to Stackdriver using Python client occasionally not being logged


Logs which I have written using the Python client occasionally don't appear in the web console. These should turn up in the global area under the default python logger. Only a very small number of them actually get there, with no real pattern as to which do and which don't. I'm running within the container engine and stackdriver logging is enabled.

My code looks like:

    import logging
    import google.cloud.logging
    client = google.cloud.logging.Client()
    client.setup_logging(log_level=logging.INFO)
    logging.info("Test")

Everything I log like this does get picked up on stdout but I want to use the python logging framework to have levels properly picked up. Any suggestions where I've gone wrong?


Solution

  • This was solved by updating the Google Cloud Python SDK version. We had it pinned to 0.22.0 but it had been updated to 0.24.0. After updating it appears to work as expected.