ca5
2/17/2014 - 8:17 AM

logging.py

import logging.config
logging.config.fileConfig(LOGGING_CONFIG_FILE)
logger = logging.getLogger()
logger.debug("debug log") # stderrに "2014/02/17 16:03:52 DEBUG [logging:4] debug log"

''' LOGGING_CONFIG_FILE
[loggers]
keys=root

[handlers]
keys=default

[formatters]
keys=basic

[logger_root]
level=DEBUG
handlers=default

[handler_default]
class=StreamHandler
level=DEBUG
formatter=basic
args=(sys.stderr,)

[formatter_basic]
format=%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s
datefmt=%Y/%m/%d %H:%M:%S
'''