Chinaunix首页 | 论坛 | 博客
  • 博客访问: 348413
  • 博文数量: 79
  • 博客积分: 3053
  • 博客等级: 中校
  • 技术积分: 861
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-27 20:43
文章分类

全部博文(79)

文章存档

2012年(3)

2011年(21)

2010年(15)

2009年(40)

分类: 系统运维

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")

阅读(909) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~