15
嘗試使用日誌記錄配置文件來實現TimedRotatinigFileHandler
。Python 2.4.3:ConfigParser.NoSectionError:無部分:'格式化程序'
只是不會採取配置文件出於某種原因。
任何建議表示讚賞。
x.py:
import logging
import logging.config
import logging.handlers
logging.config.fileConfig("x.ini")
MyLog = logging.getLogger('x')
MyLog.debug('Starting')
x.ini:
[loggers]
keys=root
[logger_root]
level=NOTSET
handlers=trfhand
[handlers]
keys=trfhand
[handler_trfhand]
class=handlers.TimedRotatingFileHandler
when=M
interval=1
backupCount=11
formatter=generic
level=DEBUG
args=('/var/log/x.log',)
[formatters]
keys=generic
[formatter_generic]
class=logging.Formatter
format=%(asctime)s %(levelname)s %(message)s
datefmt=
Traceback (most recent call last):
File "x.py", line 5, in ?
logging.config.fileConfig("x.ini")
File "/usr/lib/python2.4/logging/config.py", line 76, in fileConfig
flist = cp.get("formatters", "keys")
File "/usr/lib/python2.4/ConfigParser.py", line 511, in get
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'formatters'
感謝
謝謝Adam!就是這樣。 – user981163
什麼是修復? – ProNeticas