python-colorlog
python-colorlog is a lightweight Python library that adds colored output to the standard logging module, making log messages easier to read in terminals. It's a stable, mature project in maintenance mode with minimal dependencies (colorama on Windows) and broad platform support through official Linux distribution packages.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | borntyping/python-colorlog |
| Owner | borntyping |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 963 |
| Forks | 99 |
| Open issues | 1 |
| Latest release | v6.10.1 (2025-10-16) |
| Last updated | 2025-10-16 |
| Source | https://github.com/borntyping/python-colorlog |
What python-colorlog is
A pure-Python logging formatter that wraps Python's standard logging.Formatter to inject ANSI color escape codes based on log level. Supports custom colors, secondary log colors, multiple escape code combinations (bold, background, bright variants), and integrates with logging.config dictConfig and fileConfig. Requires Python 3.6+; colorama is auto-initialized on Windows.
Get the python-colorlog source
Clone the repository and explore it locally.
git clone https://github.com/borntyping/python-colorlog.gitcd python-colorlog# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Instantiate ColoredFormatter with format string and log_colors dict; no code changes to logger calls required—formatter injection point only.
- Use reset=True (default) to automatically append color reset codes and prevent color bleed across subsequent log lines.
- For non-TTY environments (files, CI/CD), detect output type and conditionally apply ColoredFormatter to avoid embedding ANSI codes in static logs.
- secondary_log_colors provides multi-attribute coloring (e.g., different colors for level vs. message) without custom formatter subclassing.
- Custom log levels (logging.addLevelName) are supported; add corresponding entries to log_colors dict for each custom level.
When to avoid it — and what to weigh
- Structured/machine-readable logging required — colorlog outputs ANSI escape codes and is intended for human-readable terminal output. For JSON, syslog, or log aggregation pipelines, use structured logging libraries (e.g., structlog, jsonlog).
- Production server logging to files — ANSI codes pollute file-based logs and log aggregation systems. Reserve colorlog for stderr/stdout handlers in development; use plain formatters for file handlers in production.
- Non-terminal output (pipes, redirects, CI/CD logs) — ANSI color codes in piped or captured output create noise. Consider disabling colors when output is not a TTY, or use conditional formatter selection based on sys.stdout.isatty().
- Windows console without colorama compatibility verification — While colorama is bundled and auto-initialized, Windows console ANSI support varies by OS version. Requires testing on target Windows editions before production deployment.
License & commercial use
MIT License (permissive, OSI-approved). Full text included in README: allows unrestricted use, modification, and distribution in source and binary form, provided copyright notice and license text are retained. No attribution required in binary distributions.
MIT License permits commercial use without restrictions. No licensing fees, no proprietary restrictions, no copyleft obligations. Safe for proprietary applications. No warranty provided (standard MIT disclaimer applies); review liability implications for mission-critical systems.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
No cryptography, network calls, or privilege escalation. ANSI escape code injection risk exists if log message content is untrusted and used in format strings with log_color variables—sanitize user-controlled log values before logging. colorlog itself does not sanitize or escape; it assumes logger calls are trusted. Standard logging module best practices apply (avoid logging sensitive data).
Alternatives to consider
structlog
Modern, feature-rich structured logging library with built-in color support, JSON output, and processor chains. Better for production systems and log aggregation; heavier weight than colorlog.
loguru
All-in-one logging replacement for Python with colors, file rotation, async handling, and simplified API. More opinionated and heavyweight; abandons stdlib logging in favor of custom logger.
colorama (standalone)
Lower-level cross-platform ANSI color library. Requires manual color management in log format strings; more control but less integration with logging module than colorlog.
Build on python-colorlog with DEV.co software developers
python-colorlog integrates in minutes with zero external dependencies. Evaluate it in your development workflow or discuss how to integrate structured logging at scale with our team.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
python-colorlog FAQ
Will colorlog pollute my log files with ANSI codes?
Does colorlog work on Windows?
Can I use custom colors beyond the predefined palette?
Is colorlog actively maintained?
Work with a software development agency
Adopting python-colorlog is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source observability software in production.
Ready to improve your CLI logging visibility?
python-colorlog integrates in minutes with zero external dependencies. Evaluate it in your development workflow or discuss how to integrate structured logging at scale with our team.