Logging to different addressees

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue Jul 15 15:51:11 CEST 2008

On Jul 15, 1:27 pm, McA <andreas.m... at web.de> wrote:
> Hi all,
> I need a recommendation. I would to like to use theloggingmodule to
> create log messages the following way:
> a) Every log message does go to  a admin sink.
> b) Theloggingof special messages should go to the admin sink AND to
> a sink specifically for
> a certain addressee.
> c) I don't want to write the log message to two different loggers for
> that purpose. I would like to do it this way:
> common_logger.log('bla')   -> message to admin sink
> certain_logger.log('something' -> message to admin sink and addressee-
> sink
> d) Filtering and debug level should work as expected.
> I could I achieve this in a elegant way?
> Best regards
> Andreas Mock

Add a handler to the root logger (or common_logger) to send to the
admin sink.
Add a handler to certain_logger to send to the addressee sink.
If you added the admin sink handler to the root logger, you're done.
Otherwise, you need to ensure that certain_logger is a child of


Vinay Sajip

More information about the Python-list mailing list