0

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)

1 Answer 1

1

you could do

list(map(lambda logger:logger.info(msg),[logger1,logger2]))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.