分类: 系统运维
2011-12-15 18:28:43
#基本配置
[loggers]
keys = root, tt, sqlalchemy, auth
[handlers]
keys = console, rotating, paster
[formatters]
keys = generic
# If you create additional loggers, add them as a key to [loggers]
#日志项
[logger_root]
level = DEBUG
handlers = paster
formatter = generic
[logger_tt]
level = DEBUG
handlers = console
qualname = tt
[logger_sqlalchemy]
level = INFO
handlers = console
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)
# If you create additional handlers, add them as a key to [handlers]
#定义日志文件及切换
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[handler_paster]
class = handlers.RotatingFileHandler
args = ('paster.log','a', 2000000, 5)
level = NOTSET
formatter = generic
# If you create additional formatters, add them as a key to [formatters]
#定义日志格式
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
以上配置后,在controllers等模块中使用
import logging
log = logging.getLogger(__name__)
log.info("test")
log.debug("test")