[New-bugs-announce] [issue31732] Add TRACE level to the logging module

STINNER Victor report at bugs.python.org
Mon Oct 9 08:29:21 EDT 2017

New submission from STINNER Victor <victor.stinner at gmail.com>:

The logging module has already 5 log levels: CRITICAL, ERROR, WARNING, INFO, DEBUG.
(I don't count NOTSET, I don't consider it to be "usable", at least not in an application or a library.)

For a large application, sometimes we need to a 6th level since DEBUG might be too verbose for some customers (random value: 1 MiB of log per minute). The OpenStack project has 2 additional logging levels: TRACE and AUDIT. See the Oslo Log project used by all OpenStack projects:


The typical usage for TRACE is to log a Python traceback when an exception is logged:

logger.debug("Oops: something bad happened! %s", exc)
for line in my_exception_formatter(exc):

In software development, "trace" term is commonly associated to "debug traces", as in "How to get debug traces?". Or more commonly in Python: "traceback" or "stack trace".

An additional level helps to filter logs, but also to colorize logs differently.


I don't propose to add a new AUDIT level since it's not well defined and it's less popular in OpenStack. For example, the Oslo Log module adds a new logger.trace() method, but no logger.audit().

components: Library (Lib)
messages: 303945
nosy: haypo
priority: normal
severity: normal
status: open
title: Add TRACE level to the logging module
versions: Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list