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()
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.