Reputation: 1070
Looking for some confirmation if I have checked all the documentation correctly and some functionality is in non-existence w.r.t. to logging
in Python.
Having two instances of a logger in Python. Now I would log the same message to both logger1 and logger2 instances.
import logging
logger1 = logging.getLogger('logger1')
logger2 = logging.getLogger('logger2')
Is there some function of logging
which supports this? Or should I simply define variable or create my own function or to log to both instances?
msg = "some log message..."
logger1.info(msg)
logger2.info(msg)
What I maybe expected is a (out of the box) functionality which provides
logging.info([logger1,logger2],msg)
or logger1.logger2.info(msg)
Upvotes: 0
Views: 83
Reputation: 26
you could do
list(map(lambda logger:logger.info(msg),[logger1,logger2]))
Upvotes: 1