Created
May 13, 2014 11:18
-
-
Save starlightsys/cca82963368800015e5c to your computer and use it in GitHub Desktop.
Example of using the Python logging library.
This file contains 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 | |
[handlers] | |
keys=consoleHandler,fileHandler | |
[formatters] | |
keys=simpleFormatter | |
[logger_root] | |
level=NOTSET | |
handlers=fileHandler | |
[handler_fileHandler] | |
class=FileHandler | |
level=DEBUG | |
formatter=simpleFormatter | |
args=("log/debug.log", "a") | |
[handler_consoleHandler] | |
class=StreamHandler | |
level=DEBUG | |
formatter=simpleFormatter | |
args=(sys.stdout,) | |
[formatter_simpleFormatter] | |
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s | |
datefmt= |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import logging, logging.config | |
logging.config.fileConfig( "config/logging.conf" ) | |
logger = logging.getLogger( __name__ ) | |
# ... rest of the program |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment