Star us on GitHub
Star
Menu

Python Logging Quick Start

Learn how to set up highlight.io Python log ingestion without a logging library.

1

Set up your frontend highlight.io integration.

First, make sure you've followed the frontend getting started guide.

2

Install the highlight-io python package.

Download the package from pypi and save it to your requirements. If you use a zip or s3 file upload to publish your function, you will want to make sure highlight-io is part of the build.

poetry add highlight-io
Copy
# or with pip pip install highlight-io
Copy
3

Initialize the Highlight SDK.

Setup the SDK with instrument_logging enabled.

import highlight_io H = highlight_io.H("<YOUR_PROJECT_ID>", instrument_logging=True)
Copy
4

Call the built-in Python logging library.

Logs are reported automatically from the builtin logging methods (as long as instrument_logging=True is provided to the highlight_io.H constructor). Visit the highlight logs portal and check that backend logs are coming in. Arguments passed as a dictionary as the second parameter will be interpreted as structured key-value pairs that logs can be easily searched by.

import logging def main(): logging.info('hello, world!') logging.warn('whoa there', {'key': 'value'})
Copy
5

Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.