LogCore

A production-ready structured logging library for Python.

LogCore wraps Python’s stdlib logging with a single ergonomic entrypoint, structured JSON output, async-safe correlation IDs, automatic sensitive-data redaction, OpenTelemetry integration, and intelligent log sampling — all with zero required dependencies.

from logcore import get_logger

log = get_logger("myapp", json=True)
log.info("user login", user="alice", role="admin")

At a glance

  • Single entrypoint. get_logger(name) returns a configured, cached logger — no dictConfig, no handler/formatter wiring.

  • Structured by default. JSON output mode produces records that log aggregators can query directly.

  • Async-safe correlation IDs. Per-task isolation via contextvars.

  • Automatic redaction. Sensitive fields (passwords, tokens, keys) are partially masked — enough to confirm a value was present without leaking it.

  • OpenTelemetry-aware. trace_id and span_id injected automatically when a span is active.

  • Tail-based sampling. Buffer records per request, flush them on error, drop them on success. Pay nothing for healthy traffic; keep everything when something breaks.

  • Strict typing. PEP 561–compliant py.typed marker; mypy-clean.

Install

pip install logcore

Optional extras:

pip install "logcore[colors]"  # colored console output
pip install "logcore[otel]"    # OpenTelemetry integration

Where to go next