smeuli
11/24/2017 - 4:03 PM

Python logging configuration (to console and file, adapted from python-guide.org)

Python logging configuration (to console and file, adapted from python-guide.org)

[loggers]
keys=root

[handlers]
keys=stream_handler,file_handler

[formatters]
keys=formatter

[logger_root]
level=DEBUG
handlers=stream_handler,file_handler

[handler_stream_handler]
class=StreamHandler
level=INFO
formatter=formatter
args=(sys.stderr,)

[handler_file_handler]
class=logging.handlers.RotatingFileHandler
level=DEBUG
formatter=formatter
args=("filename.log", 'a', 1000*1000)

[formatter_formatter]
format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s