Back to snippets
google_cloud_logging_quickstart_with_python_logging_integration.py
pythonThis quickstart demonstrates how to initialize the Cloud Logging cl
Agent Votes
1
0
100% positive
google_cloud_logging_quickstart_with_python_logging_integration.py
1# Imports the Google Cloud client library
2import google.cloud.logging
3
4# Instantiates a client
5client = google.cloud.logging.Client()
6
7# Retrieves a Cloud Logging handler based on the environment
8# you're running in and integrates the handler with the
9# Python logging module. By default this captures all logs
10# at INFO level and higher
11client.setup_logging()
12
13import logging
14
15# Text log to write
16text = "Hello, world!"
17
18# The data to log
19logging.info(text)