谁能给下如下配置文件的含义 多谢 急

power0811 2009-12-15 10:03:11
#logging.conf

[loggers]
keys=root,example

[handlers]
keys=consoleHandler,rotateFileHandler

[formatters]
keys=simpleFormatter

[formatter_simpleFormatter]
format=[%(asctime)s](%(levelname)s)%(name)s : %(message)s

[logger_root]
level=DEBUG
handlers=consoleHandler,rotateFileHandler

[logger_example]
level=DEBUG
handlers=consoleHandler,rotateFileHandler
qualname=example
propagate=0

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[handler_rotateFileHandler]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('test.log', 'a', 5000, 9) #尤其是这个 每个参数都是什么 意思 我想让它每天生成一个如:2009_12_17_test.log该怎么办
...全文
114 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
power0811 2009-12-16
  • 打赏
  • 举报
回复
就是不清楚 这个配置文件的含义 能否指教一下 多谢
power0811 2009-12-15
  • 打赏
  • 举报
回复
在windows环境下开发 在linux环境下运行 呵呵 多谢指教
thy38 2009-12-15
  • 打赏
  • 举报
回复
你的应用环境是什么啊?
nietsche 2009-12-15
  • 打赏
  • 举报
回复
按需配置就可以啊!
notax 2009-12-15
  • 打赏
  • 举报
回复

import logging
import logging.config
....
logging.config.fileConfig(your_log_config_file, xxxx) #<<<<<应该是 your_log_config_file
mylogger = logging.getLogger("example")
mylogger.info("testing")
....

notax 2009-12-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 power0811 的回复:]
啊 不好意思 我是在网上找的配置文件 是供 logging.config方法来使用的 现在不知道怎么配 能否帮忙给出这个配置文件的含义 多谢
[/Quote]

import logging
import logging.config
....
logging.config.fileConfig(your_log_file, xxxx)
mylogger = logging.getLogger("example")
mylogger.info("testing")
....
power0811 2009-12-15
  • 打赏
  • 举报
回复
啊 不好意思 我是在网上找的配置文件 是供 logging.config方法来使用的 现在不知道怎么配 能否帮忙给出这个配置文件的含义 多谢
notax 2009-12-15
  • 打赏
  • 举报
回复
[Quote=引用楼主 power0811 的回复:]
#logging.conf

2009_12_17_test.log该怎么办

[/Quote]

backupCount = 9

第10个文件会盖掉第一个文件,所以,用日子表示没多大意义

notax 2009-12-15
  • 打赏
  • 举报
回复
[handler_rotateFileHandler]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('test.log', 'a', 5000, 9)



class logging.handlers.RotatingFileHandler(filename[, mode[, maxBytes[, backupCount[, encoding[, delay]]]]])¶



filename => 'test.log'
mode => 'a' => append
maxBytes => max. size of each log file
backupCount => 9 files rotations each round, similar to logrotate on Linux

thy38 2009-12-15
  • 打赏
  • 举报
回复
我是意思是:这个配置文件是从哪儿搞来的?总不能让我瞎猜吧?

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧