Google cloud logging, using python with docker container

7/21/2015

I have simple python app and want to use google cloud logging. I use docker and run it with kubernetes.

How can i send the logs to google cloud logging?

import time
import logging

def main():
    logging.basicConfig()
    logging.getLogger().setLevel(logging.INFO)
    try:
        while True:
            logging.info('Working...')
            time.sleep(1)
    except KeyboardInterrupt:
        logging.info('Stopped working')
        pass;

if __name__ == '__main__':
    main()
-- Miguel Fermin
google-cloud-logging
google-compute-engine
google-kubernetes-engine
kubernetes
python

1 Answer

7/21/2015

If you configure your logger to write to stdout, Kubernetes will automatically send it to Google Cloud Logging for you.

Otherwise you'll have to use a sidecar container to collect the logs and upload them for you, like in this example.

-- Alex Robinson
Source: StackOverflow