How to disable logging on the standard error stream?
You can use:
logging.basicConfig(level=your_level)
where your_level is one of those:
'debug': logging.DEBUG,'info': logging.INFO,'warning': logging.WARNING,'error': logging.ERROR,'critical': logging.CRITICAL
So, if you set your_level to logging.CRITICAL, you will get only critical messages sent by:
logging.critical('This is a critical error message')
Setting your_level to logging.DEBUG will show all levels of logging.
For more details, please take a look at logging examples.
In the same manner to change level for each Handler use Handler.setLevel() function.
import loggingimport logging.handlersLOG_FILENAME = '/tmp/logging_rotatingfile_example.out'# Set up a specific logger with our desired output levelmy_logger = logging.getLogger('MyLogger')my_logger.setLevel(logging.DEBUG)# Add the log message handler to the loggerhandler = logging.handlers.RotatingFileHandler( LOG_FILENAME, maxBytes=20, backupCount=5)handler.setLevel(logging.CRITICAL)my_logger.addHandler(handler)