The coloredlogs package enables colored terminal output for Python’s logging module. The ColoredFormatter class inherits from logging.Formatter and uses ANSI escape sequences to render your logging messages in color. It uses only standard colors so it should work on any UNIX terminal. It’s currently tested on Python 3.10 and newer. On Windows coloredlogs automatically tries to enable native ANSI support (on up-to-date Windows 10 installations) and falls back on using colorama (if installed). Here is a screen shot of the demo that is printed when the command coloredlogs --demo is executed:
Note that the screenshot above includes custom logging levels defined by my verboselogs package: if you install both coloredlogs and verboselogs it will Just Work ( verboselogs is of course not required to use coloredlogs ).
This is a continuation of coloredlogs , originally written by Peter Odding ( @xolox ), whose last release was 15.0.1 in 2021. The original author is not involved in this continuation. Should he return or want the project back, it will be handed over.
This continuation is maintained by one person with AI agents, without independent review . In practice that means:
Changes are written and checked with the help of AI coding agents. A second AI model is used as an additional check. That is a tool, not an independent human review.
Changes are written and checked with the help of AI coding agents. A second AI model is used as an additional check. That is a tool, not an independent human review.
There is no second maintainer who reads every change before a release.
There is no second maintainer who reads every change before a release.
The goal is to keep the package working on current Python versions. The API and behaviour are meant to stay the same. Licence (MIT) and copyright are unchanged.
The goal is to keep the package working on current Python versions. The API and behaviour are meant to stay the same. Licence (MIT) and copyright are unchanged.
Releases are built by GitHub Actions and published to PyPI through Trusted Publishing, so every release can be traced to a tagged commit.
Releases are built by GitHub Actions and published to PyPI through Trusted Publishing, so every release can be traced to a tagged commit.
Install it with pip install coloredlogs-ng . The import name is unchanged ( import coloredlogs ), so do not install it to the original coloredlogs distribution: both ship the same files and would overwrite each other.
If you depend on this package in production, please pin a version and read the changelog before upgrading. Reviews, bug reports and co-maintainers are welcome.
The coloredlogs package is available on PyPI which means installation should be as simple as:
There’s actually a multitude of ways to install Python packages (e.g. the per user site-packages directory , virtual environments or just installing system wide) and I have no intention of getting into that discussion here, so if this intimidates you then read up on your options before returning to these instructions 😉.
Optional dependencies
Native ANSI support on Windows requires an up-to-date Windows 10 installation. If this is not working for you then consider installing the colorama package:
Once colorama is installed it will be used automatically.
Here’s an example of how easy it is to get started:
Format of log messages
The ColoredFormatter class supports user defined log formats so you can use any log format you like. The default log format is as follows:
This log format results in the following output:
You can customize the log format and styling using environment variables as well as programmatically, please refer to the online documentation for details.
Enabling millisecond precision
If you’re switching from logging.basicConfig() to coloredlogs.install() you may notice that timestamps no longer include milliseconds. This is because coloredlogs doesn’t output milliseconds in timestamps unless you explicitly tell it to. There are three ways to do that:
The easy way is to pass the milliseconds argument to coloredlogs.install() : coloredlogs.install(milliseconds=True) This became supported in release 7.1 (due to #16 ).
The easy way is to pass the milliseconds argument to coloredlogs.install() :
This became supported in release 7.1 (due to #16 ).
Alternatively you can change the log format to include ‘msecs’ : %(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s Here’s what the call to coloredlogs.install() would then look like: coloredlogs.install(fmt='%(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s') Customizing the log format also enables you to change the delimiter that separates seconds from milliseconds (the comma above). This became possible in release 3.0 which added support for user defined log formats.
Alternatively you can change the log format to include ‘msecs’ :
Here’s what the call to coloredlogs.install() would then look like:
Customizing the log format also enables you to change the delimiter that separates seconds from milliseconds (the comma above). This became possible in release 3.0 which added support for user defined log formats.
If the use of %(msecs)d isn’t flexible enough you can instead add %f to the date/time format, it will be replaced by the value of %(msecs)03d . Support for the %f directive was added to release 9.3 (due to #45 ).
If the use of %(msecs)d isn’t flexible enough you can instead add %f to the date/time format, it will be replaced by the value of %(msecs)03d . Support for the %f directive was added to release 9.3 (due to #45 ).
Custom logging fields
The following custom log format fields are supported:
%(hostname)s provides the hostname of the local system.
%(hostname)s provides the hostname of the local system.
%(programname)s provides the name of the currently running program.
%(programname)s provides the name of the currently running program.
%(username)s provides the username of the currently logged in user.
%(username)s provides the username of the currently logged in user.
When coloredlogs.install() detects that any of these fields are used in the format string the applicable logging.Filter subclasses are automatically registered to populate the relevant log record fields.
Changing text styles and colors
The online documentation contains an example of customizing the text styles and colors .
Colored output from cron
When coloredlogs is used in a cron job, the output that’s e-mailed to you by cron won’t contain any ANSI escape sequences because coloredlogs realizes that it’s not attached to an interactive terminal. If you’d like to have colors e-mailed to you by cron there are two ways to make it happen:
Modifying your crontab
Here’s an example of a minimal crontab:
The coloredlogs program is installed when you install the coloredlogs Python package. When you execute coloredlogs --to-html your-command it runs your-command under the external program script (you need to have this installed). This makes your-command think that it’s attached to an interactive terminal which means it will output ANSI escape sequences which will then be converted to HTML by the coloredlogs program. Yes, this is a bit convoluted, but it works great :-)
Modifying your Python code
The ColoredCronMailer class provides a context manager that automatically enables HTML output when the $CONTENT_TYPE variable has been correctly set in the crontab.
This requires my capturer package which you can install using pip install 'coloredlogs-ng[cron]' . The [cron] extra will pull in capturer 2.4 or newer which is required to capture the output while silencing it - otherwise you’d get duplicate output in the emails sent by cron .
The context manager can also be used to retroactively silence output that has already been produced, this can be useful to avoid spammy cron jobs that have nothing useful to do but still email their output to the system administrator every few minutes :-).
The latest version of coloredlogs is available on PyPI and GitHub . The online documentation is available on Read The Docs and includes a changelog . For bug reports please create an issue on GitHub . Please do not the original author problems with this continuation.
This software is licensed under the MIT license .
Release files for coloredlogs-ng 16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation .
Source distribution (sdist)
Built distribution (wheel)
Total release size: 323.7 kB
Release files / coloredlogs_ng-16.0.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations , which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Release files / coloredlogs_ng-16.0-py3-none-any.whl
Provenance describes where a file came from. On PyPI, provenance is shared via attestations , which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Security for coloredlogs-ng 16.0
Provenance describes where a file came from. On PyPI, provenance is shared via attestations , which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Both files in this release have been uploaded with provenance metadata.
Attestation for coloredlogs_ng-16.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Attestation for coloredlogs_ng-16.0-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
Release history Release notifications | RSS feed
Nov 23, 2026 2 release files Full provenance
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
