logging module - how to include method's class name when using %(funcName)

dieter dieter at handshake.de
Tue Sep 11 01:17:12 EDT 2018


Malcolm Greene <python at bdurham.com> writes:
> I'm using the Python logging module and looking for a way to include a
> method's class name when using %(funcName). Is this possible?

If it does not happen automatically, the standard logging components
will not let you do it (the name "funcName" is rather explicit;
you get what the name promises).

However, all logging components can be customized. The logging
implementation has a fine grained architecture (read the
documentation of the "logging" package). The component
for your kind of customization is likely called "formatter".
By registering you own "formatter", you will be able to get
what you want.




More information about the Python-list mailing list