{"id":622,"library":"coloredlogs","title":"Coloredlogs: Colored Terminal Output for Python's Logging Module","description":"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.","status":"active","version":"15.0.1","language":"python","source_language":"en","source_url":"https://github.com/xolox/python-coloredlogs","tags":["logging","terminal","colors","cli","development","log-formatting"],"install":[{"cmd":"pip install coloredlogs","lang":"bash","label":"Standard Installation"},{"cmd":"pip install 'coloredlogs[cron]'","lang":"bash","label":"Installation with Cron features"}],"dependencies":[{"reason":"Required for general functionality and date/time formatting.","package":"humanfriendly","optional":false},{"reason":"Optional for enabling native ANSI escape sequence support on older Windows versions (pre-Windows 10 build 14393). It is automatically used if installed.","package":"colorama","optional":true},{"reason":"Required when installing with the 'cron' extra for capturing output.","package":"capturer","optional":true}],"imports":[{"note":"The primary interaction is through module-level functions like `coloredlogs.install()`.","symbol":"coloredlogs","correct":"import coloredlogs, logging"},{"note":"While `ColoredFormatter` can be imported and used directly, `coloredlogs.install()` is the recommended and simpler way to integrate colored logging as it handles handler setup.","symbol":"ColoredFormatter","correct":"from coloredlogs import ColoredFormatter"}],"quickstart":{"code":"import coloredlogs, logging\n\n# Create a logger object. By default, coloredlogs.install()\n# will apply to the root logger if no logger is specified.\nlogger = logging.getLogger(__name__)\n\n# Install coloredlogs on the logger.\n# You can also pass level='INFO' or other levels.\ncoloredlogs.install(level='DEBUG', logger=logger)\n\n# Some examples of log messages.\nlogger.debug('This is a debug message')\nlogger.info('This is an info message')\nlogger.warning('This is a warning message')\nlogger.error('This is an error message')\nlogger.critical('This is a critical message')","lang":"python","description":"This quickstart demonstrates how to import `coloredlogs` and the standard `logging` module, create a logger, and then apply colored output using `coloredlogs.install()` to a specific logger with a 'DEBUG' level. Log messages at different severity levels will then be displayed with corresponding colors in the terminal."},"warnings":[{"fix":"If you previously relied on automatic system logging on these platforms, you may need to explicitly configure it or adjust your logging setup.","message":"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.","severity":"breaking","affected_versions":"15.0 and later"},{"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`.","message":"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.","severity":"breaking","affected_versions":"14.0 and later"},{"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.","message":"`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`.","severity":"gotcha","affected_versions":"All 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.","message":"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.","severity":"breaking","affected_versions":"6.0 and later"},{"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.","message":"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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T16:51:25.377Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed using pip: `pip install coloredlogs` or, for more robust environment management, `python -m pip install 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.","error":"ModuleNotFoundError: No module named 'coloredlogs'"},{"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`.\n\n```python\nimport coloredlogs, logging, sys\n\n# Force colors and ensure output goes to stdout\ncoloredlogs.install(level='DEBUG', isatty=True, stream=sys.stdout)\n```","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.","error":"coloredlogs not displaying colors (e.g., in Docker, PyCharm, or when redirecting output)"},{"fix":"Explicitly set the desired logging level for the root logger or the specific logger you are configuring before (or within) `coloredlogs.install()`.\n\n```python\nimport coloredlogs, logging\n\n# Configure the root logger to show DEBUG messages\nlogging.basicConfig(level=logging.DEBUG)\ncoloredlogs.install(level='DEBUG')\n\n# Alternatively, if targeting a specific logger:\n# logger = logging.getLogger('my_app')\n# logger.setLevel(logging.DEBUG)\n# coloredlogs.install(level='DEBUG', logger=logger)\n```","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.","error":"coloredlogs debug messages not showing (or other log levels not appearing)"},{"fix":"Ensure the format string explicitly includes `%(levelname)s` and modify `coloredlogs.DEFAULT_FIELD_STYLES` directly to apply custom styles before calling `install()`.\n\n```python\nimport coloredlogs, logging\n\n# Customize the style for the 'levelname' field\ncoloredlogs.DEFAULT_FIELD_STYLES['levelname'] = {'color': 'magenta', 'bold': True}\n\n# Install coloredlogs with a format string that includes levelname\ncoloredlogs.install(\n    level='INFO',\n    fmt='%(asctime)s %(levelname)s %(message)s'\n)\n```","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`.","error":"coloredlogs custom levelname style not working or 'levelname' not appearing in log output"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"15.0.1","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":3.3,"disk_size":"18.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":3.3,"disk_size":"18.7M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.11,"mem_mb":3.3,"disk_size":"18.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.11,"mem_mb":3.3,"disk_size":"18.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":0.11,"mem_mb":3.3,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.11,"mem_mb":3.3,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":3.3,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":3.3,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.16,"mem_mb":3.8,"disk_size":"20.8M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.16,"mem_mb":3.8,"disk_size":"20.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.18,"mem_mb":3.8,"disk_size":"20.8M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.19,"mem_mb":3.8,"disk_size":"20.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.14,"mem_mb":3.8,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.15,"mem_mb":3.8,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":3.8,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":3.8,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":3.7,"disk_size":"12.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":3.7,"disk_size":"12.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":3.7,"disk_size":"12.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":3.7,"disk_size":"12.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.13,"mem_mb":3.7,"disk_size":"13M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.14,"mem_mb":3.7,"disk_size":"13M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":3.7,"disk_size":"13M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":3.7,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":4.6,"disk_size":"12.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":4.6,"disk_size":"12.2M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":4.2,"disk_size":"12.2M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":4.2,"disk_size":"12.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.14,"mem_mb":4.6,"disk_size":"13M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.14,"mem_mb":4.6,"disk_size":"13M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":4.2,"disk_size":"13M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":4.2,"disk_size":"13M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":3.2,"disk_size":"18.3M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.08,"mem_mb":3.2,"disk_size":"18.2M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.08,"mem_mb":3.2,"disk_size":"18.3M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.08,"mem_mb":3.2,"disk_size":"18.2M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.9,"import_time_s":0.07,"mem_mb":3.2,"disk_size":"19M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":0.07,"mem_mb":3.2,"disk_size":"19M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"cron","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":3.2,"disk_size":"19M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":3.2,"disk_size":"19M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}