Skip to main content

structlog-configfile

Helpers to configure structlog together with standard-library logging from a small configuration module.

Installation

pip install structlog-configfile

Quick start

Replace the standard structlog logger factory with the package helper:

import structlog_configfile

logger = structlog_configfile.get_logger()
logger.info("hello", user="alice")

This loads the built-in defaults and configures both structlog and stdlib logging.

Using a custom configuration file

You can point the helper at your own Python configuration module:

import structlog_configfile

logger = structlog_configfile.get_logger(config_file="path/to/my_config.py" [, struct_log_logger_args])

Using a custom configuration file

You can point the helper at your own Python configuration module:

import custom_module.logging.config

logger = structlog_configfile.get_logger(config_file=custom_module.logging.config [, struct_log_logger_args])

You can also set the environment variable STRUCTLOG_CONFIG_FILE to avoid passing the path explicitly.

Example configuration module:

from pathlib import Path
import structlog

logging_config_file = Path(__file__).parent.joinpath("logging.yaml")

pre_process_processors = [
    structlog.processors.TimeStamper(fmt="iso"),
]

structlog_processors = []
logging_processors = []
post_process_processors = []
renderer = structlog.processors.JSONRenderer()
handleStdlib = True

Supported configuration knobs

The configuration module can define the following values:

  • logging_config_file: path to the stdlib logging configuration file (https://docs.python.org/3/library/logging.config.html)
  • pre_process_processors: processors applied before other processors
  • structlog_processors: processors used for structlog logs
  • logging_processors: processors used for stdlib logging
  • post_process_processors: processors applied after all others
  • renderer: the final renderer used by the logging formatter
  • stdlib_preprocessor: processors for stdlib log preparation
  • stdlib_processor: processors for stdlib log handling
  • stdlib_postprocessor: processors applied after stdlib processing
  • embeds_std_lib: enable or disable stdlib logging setup

Logging configuration file formats

The file referenced by logging_config_file can be a Jinja template or a YAML, JSON, or TOML file. The package will load it and use it for stdlib logging configuration.

Notes

The package exposes both get_logger() and getLoger() for compatibility.

Metadata

Release files for structlog-configfile 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structlog-configfile 1.1.0
File Size Uploaded
structlog_configfile-1.1.0.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for structlog-configfile 1.1.0
File Interpreter ABI Platform
structlog_configfile-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / structlog_configfile-1.1.0.tar.gz

Download URL structlog_configfile-1.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
135f2e1eac06337d05e29e527a0343a397ca09d7ba5aae46d1d9b8d0e84c757a
BLAKE2b-256 checksum
How to use checksums
a39a0136fe093fd6d658624ce90b0102b9260d2129c3cd9a2d510b87d4d04271
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / structlog_configfile-1.1.0-py3-none-any.whl

Download URL structlog_configfile-1.1.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3647e63be478f92e6bdcf84af76a12b6c9404a26ffe39e4bf5230c169eb557e
BLAKE2b-256 checksum
How to use checksums
3df7aebf31c19163ecf81ae1d6d34e5a27c73e78ec95ceec5ce7dbdfe0877edd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page