I have the following python code:
import logging
import logging.config
logging.config.fileConfig('a.conf')
logging.debug('aaaa')
with the the following configuration file a.conf:
[loggers]
keys = root
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
handlers=console
level=DEBUG
[handler_console]
class = StreamHandler
level = DEBUG
format = generic
args = (sys.stdout,)
[formatter_generic]
format=%(levelname)s: %(name)s - %(message)s
The problem is however that the output of "a.py" is "aaaa" without being properly formatted with the log name or log level. Any ideas of why is this not working?
In [handler_console] you have “format = generic”
Change this to “formatter = generic”
This outputs:
DEBUG: root – aaaa