Logging from Python

Python applications can log to Seq through the Python logging API with seqlog (recommended), with pygelf and GELF, or via direct HTTP and JSON.


The seqlog package implements a Python logging adapter for Seq:

# Indexer-style"Hello, %s!", "World")

# Message template style"Hello, {name}!", name="World")

The detailed project documentation includes full configuration and usage examples.

The project is independently developed on GitHub.


pygelf is a GELF logging handler for Python.

1. Enable the Seq GELF input

See the instructions in Using GELF.

2. Install pygelf

$ pip install pygelf

3. Configure the GelfUdpHandler

from pygelf import GelfUdpHandler
import logging

logger = logging.getLogger()
logger.addHandler(GelfUdpHandler(host='', port=12201))

4. Log some events!'Hello, Seq+GELF!')

OpenTelemetry Python SDK

The OpenTelemetry Python SDK can send logs and traces to Seq. See the opentelemetry-python-sdk-to-seq example for a working example of logging and tracing from Python to Seq.

1. Install the dependencies

pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-exporter-otlp

2. Configure the SDK

Set the OTLPLogExporter endpoint to the correct OTLP endpoint.

import logging
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter
from opentelemetry._logs import set_logger_provider
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import SERVICE_NAME, Resource

# Service name is required for most backends
resource = Resource(attributes={
    SERVICE_NAME: "example service name"

# configure logging
logger_provider = LoggerProvider(resource=resource)
handler = LoggingHandler(level=logging.NOTSET, logger_provider=logger_provider)
logger = logging.getLogger(__name__)

3. Log some events!

logger.warning("The weather forecast is %s", "Overcast, 24°C")