Coloredlogs: Colored Terminal Output for Python's Logging Module
raw JSON → 15.0.1 verified Tue May 12 auth: no python install: verified quickstart: verified
coloredlogs is a Python library that enhances the default logging output by adding color formatting to log messages. It provides a simple way to make log messages more visually distinguishable, making it easier to read and interpret log output, especially when working in a terminal or command-line environment. The current version is 15.0.1. It is actively maintained with regular updates.
pip install coloredlogs Common errors
error ModuleNotFoundError: No module named 'coloredlogs' ↓
cause The 'coloredlogs' package is not installed in the Python environment being used, or there's a mismatch between the Python interpreter running the code and the one where the package was installed.
fix
Ensure the package is installed using pip:
pip install coloredlogs or, for more robust environment management, python -m pip install coloredlogs. error coloredlogs not displaying colors (e.g., in Docker, PyCharm, or when redirecting output) ↓
cause By default, 'coloredlogs' automatically detects if the output stream is an interactive terminal (TTY). In non-TTY environments like Docker containers, some IDE consoles, or when redirecting output to a file, it suppresses ANSI escape codes, leading to no colors or raw escape characters in file outputs.
fix
To force color output in non-TTY environments, pass
isatty=True to coloredlogs.install(). For PyCharm, also specify stream=sys.stdout. For Docker, ensure the container is run with a TTY (docker run -it). For viewing logs in files, use a TTY-aware viewer like less -R <logfile> or convert to HTML using coloredlogs --to-html.
import coloredlogs, logging, sys
# Force colors and ensure output goes to stdout
coloredlogs.install(level='DEBUG', isatty=True, stream=sys.stdout) error coloredlogs debug messages not showing (or other log levels not appearing) ↓
cause The Python `logging` module's root logger has a default level of `WARNING`. While `coloredlogs.install()` sets up its own handler, messages below the effective level of the root logger (or any other handler in the chain) will be filtered out before 'coloredlogs' can process them. Also, if a specific logger object is passed to `coloredlogs.install()`, only messages from that logger will be colored, not from other parts of the application or the root logger.
fix
Explicitly set the desired logging level for the root logger or the specific logger you are configuring before (or within)
coloredlogs.install().
import coloredlogs, logging
# Configure the root logger to show DEBUG messages
logging.basicConfig(level=logging.DEBUG)
coloredlogs.install(level='DEBUG')
# Alternatively, if targeting a specific logger:
# logger = logging.getLogger('my_app')
# logger.setLevel(logging.DEBUG)
# coloredlogs.install(level='DEBUG', logger=logger) error coloredlogs custom levelname style not working or 'levelname' not appearing in log output ↓
cause Customization of the `levelname` field's style may not take effect if the `fmt` string passed to `coloredlogs.install()` does not include `%(levelname)s`, or if the style override is not applied correctly to `coloredlogs.DEFAULT_FIELD_STYLES`.
fix
Ensure the format string explicitly includes
%(levelname)s and modify coloredlogs.DEFAULT_FIELD_STYLES directly to apply custom styles before calling install().
import coloredlogs, logging
# Customize the style for the 'levelname' field
coloredlogs.DEFAULT_FIELD_STYLES['levelname'] = {'color': 'magenta', 'bold': True}
# Install coloredlogs with a format string that includes levelname
coloredlogs.install(
level='INFO',
fmt='%(asctime)s %(levelname)s %(message)s'
) Warnings
breaking In version 15.0, `coloredlogs` stopped enabling system logging by default on macOS and Windows due to problematic behavior. This is a backwards incompatible change. ↓
fix If you previously relied on automatic system logging on these platforms, you may need to explicitly configure it or adjust your logging setup.
breaking Starting with version 14.0, `coloredlogs` dropped `colorama` as a *required* dependency for Windows 10 users, integrating native ANSI support instead. While `colorama` will still be used if installed, its implicit presence or absence can cause issues if not considered, especially for older Windows versions or specific environments. ↓
fix For Windows installations prior to version 10.0.14393 or if native ANSI support is not working as expected, explicitly install `colorama`: `pip install colorama`.
gotcha `coloredlogs.install()`, when called without a specific `logger` argument, applies its configuration to the *root logger*. This can unintentionally change the effective logging level for *all* loggers in your application, including those from third-party libraries, potentially silencing or making logs unexpectedly verbose. The default log level for the root logger is `INFO` when using `coloredlogs`, which differs from Python's default `WARNING`. ↓
fix Always pass a specific logger instance to `coloredlogs.install(logger=my_logger)` if you only want to affect that logger. If you intend to modify the root logger, be aware of the default `INFO` level and explicitly set `logging.getLogger().setLevel(logging.WARNING)` if Python's default `WARNING` level is desired for other parts of your application after `coloredlogs.install()` has run.
breaking In release 6.0, `coloredlogs.install()` changed its default root logger level handling and `enable_system_logging()`'s default logging level changed from `DEBUG` to `INFO`. This affected the verbosity of logs for users migrating from older versions. ↓
fix If migrating from versions older than 6.0, explicitly set `level='DEBUG'` in `coloredlogs.install()` or `coloredlogs.install(syslog='debug')` if `DEBUG` verbosity is desired.
gotcha When `coloredlogs` is active, and logging output is redirected to a file, the file will contain plain text without ANSI escape sequences (colors) by default, because `coloredlogs` detects it's not attached to an interactive terminal. This is by design, but can be a 'gotcha' if users expect colored log files for later viewing. ↓
fix This is intended behavior. If colored output in files is desired (e.g., for viewing in Vim with specific plugins or converting to HTML), specific tools or configurations are needed, such as `coloredlogs --to-html your-command` for HTML output.
Install
pip install 'coloredlogs[cron]' Install compatibility verified last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) cron wheel - 0.13s 18.8M
3.10 alpine (musl) coloredlogs wheel - 0.12s 18.7M
3.10 alpine (musl) cron - - 0.11s 18.8M
3.10 alpine (musl) coloredlogs - - 0.11s 18.7M
3.10 slim (glibc) cron wheel 1.8s 0.11s 19M
3.10 slim (glibc) coloredlogs wheel 1.6s 0.11s 19M
3.10 slim (glibc) cron - - 0.12s 19M
3.10 slim (glibc) coloredlogs - - 0.12s 19M
3.11 alpine (musl) cron wheel - 0.16s 20.8M
3.11 alpine (musl) coloredlogs wheel - 0.16s 20.7M
3.11 alpine (musl) cron - - 0.18s 20.8M
3.11 alpine (musl) coloredlogs - - 0.19s 20.7M
3.11 slim (glibc) cron wheel 1.7s 0.14s 21M
3.11 slim (glibc) coloredlogs wheel 1.7s 0.15s 21M
3.11 slim (glibc) cron - - 0.14s 21M
3.11 slim (glibc) coloredlogs - - 0.14s 21M
3.12 alpine (musl) cron wheel - 0.13s 12.6M
3.12 alpine (musl) coloredlogs wheel - 0.13s 12.5M
3.12 alpine (musl) cron - - 0.14s 12.6M
3.12 alpine (musl) coloredlogs - - 0.13s 12.5M
3.12 slim (glibc) cron wheel 1.6s 0.13s 13M
3.12 slim (glibc) coloredlogs wheel 1.5s 0.14s 13M
3.12 slim (glibc) cron - - 0.15s 13M
3.12 slim (glibc) coloredlogs - - 0.13s 13M
3.13 alpine (musl) cron wheel - 0.14s 12.3M
3.13 alpine (musl) coloredlogs wheel - 0.14s 12.2M
3.13 alpine (musl) cron - - 0.13s 12.2M
3.13 alpine (musl) coloredlogs - - 0.14s 12.1M
3.13 slim (glibc) cron wheel 1.6s 0.14s 13M
3.13 slim (glibc) coloredlogs wheel 1.6s 0.14s 13M
3.13 slim (glibc) cron - - 0.14s 13M
3.13 slim (glibc) coloredlogs - - 0.14s 13M
3.9 alpine (musl) cron wheel - 0.07s 18.3M
3.9 alpine (musl) coloredlogs wheel - 0.08s 18.2M
3.9 alpine (musl) cron - - 0.08s 18.3M
3.9 alpine (musl) coloredlogs - - 0.08s 18.2M
3.9 slim (glibc) cron wheel 1.9s 0.07s 19M
3.9 slim (glibc) coloredlogs wheel 1.8s 0.07s 19M
3.9 slim (glibc) cron - - 0.07s 19M
3.9 slim (glibc) coloredlogs - - 0.07s 19M
Imports
- coloredlogs
import coloredlogs, logging - ColoredFormatter
from coloredlogs import ColoredFormatter
Quickstart verified last tested: 2026-04-24
import coloredlogs, logging
# Create a logger object. By default, coloredlogs.install()
# will apply to the root logger if no logger is specified.
logger = logging.getLogger(__name__)
# Install coloredlogs on the logger.
# You can also pass level='INFO' or other levels.
coloredlogs.install(level='DEBUG', logger=logger)
# Some examples of log messages.
logger.debug('This is a debug message')
logger.info('This is an info message')
logger.warning('This is a warning message')
logger.error('This is an error message')
logger.critical('This is a critical message')