I am using python logging like this:
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
log = logging.getLogger()
Everything works fine. only issue is that all log messages are printed to both stdout and stderr. stdout is formatted as I expect. stderr simply prints the message itself in error stream.
I see that log.handlers
indeed contains 2 handlers. Removing the stderr one doesn't seem to have effect. Tried something like this:
for handler in log.handlers:
if handler.stream and handler.stream.name == '<stderr>':
log.handlers.remove(handler)
Any way around this issue?