Using 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.
seqlog
The seqlog
package implements a Python logging adapter for Seq:
# Indexer-style
logging.info("Hello, %s!", "World")
# Message template style
logging.info("Hello, {name}!", name="World")
The detailed project documentation includes full configuration and usage examples.
The project is independently developed on GitHub.
pygelf with GELF via UDP
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
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
logger.addHandler(GelfUdpHandler(host='127.0.0.1', port=12201))
4. Log some events!
logger.info('Hello, Seq+GELF!')
HTTP/JSON
Python applications can alternatively use the HTTP API to post events as raw JSON documents.
Updated about 5 years ago