Python logo

Table of Contents

  • Logging Cookbook
    • Using logging in multiple modules
    • Logging from multiple threads
    • Multiple handlers and formatters
    • Logging to multiple destinations
    • Custom handling of levels
    • Configuration server example
    • Dealing with handlers that block
    • Sending and receiving logging events across a network
      • Running a logging socket listener in production
    • Adding contextual information to your logging output
      • Using LoggerAdapters to impart contextual information
        • Using objects other than dicts to pass contextual information
      • Using Filters to impart contextual information
    • Use of contextvars
    • Imparting contextual information in handlers
    • Logging to a single file from multiple processes
      • Using concurrent.futures.ProcessPoolExecutor
      • Deploying Web applications using Gunicorn and uWSGI
    • Using file rotation
    • Use of alternative formatting styles
    • Customizing LogRecord
    • Subclassing QueueHandler and QueueListener- a ZeroMQ example
      • Subclass QueueHandler
      • Subclass QueueListener
    • Subclassing QueueHandler and QueueListener- a pynng example
      • Subclass QueueListener
      • Subclass QueueHandler
    • An example dictionary-based configuration
    • Using a rotator and namer to customize log rotation processing
    • A more elaborate multiprocessing example
    • Inserting a BOM into messages sent to a SysLogHandler
    • Implementing structured logging
    • Customizing handlers with dictConfig()
    • Using particular formatting styles throughout your application
      • Using LogRecord factories
      • Using custom message objects
    • Configuring filters with dictConfig()
    • Customized exception formatting
    • Speaking logging messages
    • Buffering logging messages and outputting them conditionally
    • Sending logging messages to email, with buffering
    • Formatting times using UTC (GMT) via configuration
    • Using a context manager for selective logging
    • A CLI application starter template
    • A Qt GUI for logging
    • Logging to syslog with RFC5424 support
    • How to treat a logger like an output stream
    • How to uniformly handle newlines in logging output
    • Patterns to avoid
      • Opening the same log file multiple times
      • Using loggers as attributes in a class or passing them as parameters
      • Adding handlers other than NullHandler to a logger in a library
      • Creating a lot of loggers
    • Other resources

Previous topic

Logging HOWTO

Next topic

Regular Expression HOWTO