### Navigation

- index
- modules |
- next |
- structlog documentation »

# Structured Logging for Python

Release v15.2.0 (What’s new?).

It’s dual-licensed under Apache License, version 2 and MIT, available from PyPI, the source code can be found on GitHub, the documentation at http://www.structlog.org/.

`structlog` targets Python 2.6, 2.7, 3.3, 3.4, and PyPy with no additional dependencies for core functionality.

If you need any help, visit us on `#structlog` on Freenode!

## The Pitch

`structlog` makes structured logging with incremental context building and arbitrary formatting as easy as:

    >>> from structlog import get_logger
    >>> log = get_logger()
    >>> log = log.bind(user='anonymous', some_key=23)
    >>> log = log.bind(user='hynek', another_key=42)
    >>> log.info('user.logged_in', happy=True)
    some_key=23 user='hynek' another_key=42 happy=True event='user.logged_in'

Please note that this example does not use standard library logging (but could so easily). The logger that’s returned by `get_logger()` is freely configurable and uses a simple `PrintLogger` by default.

For…

- …reasons why structured logging in general and `structlog` in particular are the way to go, consult Why….
- …more realistic examples, peek into Examples.
- …getting started right away, jump straight into Getting Started.

Since `structlog` avoids monkey-patching and events are fully free-form, you can start using it today!

## User’s Guide

### Basics

- Why…
- Getting Started
- Loggers
- Configuration
- Thread Local Context
- Processors
- Examples

### Integration with Existing Systems

`structlog` can be used immediately with any existing logger. However it comes with special wrappers for the Python standard library and Twisted that are optimized for their respective underlying loggers and contain less magic.

- Python Standard Library
  - Concrete Bound Logger
  - Processors
  - Suggested Configuration
- Twisted
  - Concrete Bound Logger
  - Processors
  - Bending Foreign Logging To Your Will
  - Suggested Configuration
- Logging Best Practices
  - Common Ideas
  - Local Logging
  - Centralized Logging

### Advanced Topics

- Custom Wrappers
- Performance

## Project Information

- How To Contribute
- License and Hall of Fame
- Changelog

## API Reference

- structlog Package
  - `structlog` Package
  - `threadlocal` Module
  - `processors` Module
  - `stdlib` Module
  - `twisted` Module

## Indices and tables

- Index
- Module Index
- Search Page

### Navigation

- index
- modules |
- next |
- structlog documentation »