This question already has an answer here:
Is it possible to have python logging messages which are INFO or DEBUG to go to stdout and WARNING or greater to go to stderr?
This question already has an answer here:
Is it possible to have python logging messages which are INFO or DEBUG to go to stdout and WARNING or greater to go to stderr?
I thought this would help:
Handler.setLevel(lvl)
Sets the threshold for this handler to lvl. Logging messages which are less severe than lvl will be ignored. When a handler is created, the level is set to NOTSET (which causes all messages to be processed).
But now I see that it wouldn't do what you want (split INFO/DEBUG from WARNING/ERROR)
That being said, you could write a custom handler (a class extending
logging.StreamHandler
for example), and overwrite theHandler.handle()
method.This seems to do what I want: