Created
January 19, 2012 21:35
-
-
Save mgedmin/1642893 to your computer and use it in GitHub Desktop.
Python logging insanity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[two] INFO: world | |
[foo] INFO: bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment