[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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.