Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python logging insanity
[loggers]
keys = root, foo
[logger_root]
handlers = stdout
level = DEBUG
[logger_foo]
qualname = foo
handlers =
[handlers]
keys = stdout
[handler_stdout]
class = StreamHandler
args = (sys.stdout,)
formatter = mine
[formatters]
keys = mine
[formatter_mine]
format = [%(name)s] %(levelname)s: %(message)s
import logging
import logging.config
one = logging.getLogger('one')
foo = logging.getLogger('foo')
logging.config.fileConfig('logpain.ini')
two = logging.getLogger('two')
one.info('hello')
two.info('world')
foo.info('bar')
# What do you expect to be printed? Neither 'one' nor 'two' are explicitly mentioned in the .ini file
[two] INFO: world
[foo] INFO: bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.