0

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?

1 Answer 1

1

In [handler_console] you have "format = generic"

Change this to "formatter = generic"

This outputs: DEBUG: root - aaaa

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.