2
아래의 코드를 Python 2에서 사용할 수 있습니다. Python 3에서이 코드를 사용했지만 오류가 발생했습니다. 누구든지 이유를 설명 할 수 있습니까?Python v3 Logging
코드 :
import logging
import logging.handlers
LOG_FILENAME = 'poller.log'
# Set up a specific logger with our desired output level
poll_logger = logging.getLogger('pollerLog')
# Add the log message handler to the logger
log_rotator = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, when='d', interval=1, backupCount=5, encoding=None, delay=False, utc=False)
poll_logger.addHandler(log_rotator)
# Roll over on application start
poll_logger.handlers[0].doRollover()
오류 : 나는 아래의 문서를 체크 아웃하고 난 어떤 차이가 표시되지 않습니다
Traceback (most recent call last):
File "logR.py", line 10, in <module>
log_rotator = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, when='d', interval=1, back
upCount=5, encoding=None, delay=False, utc=False)
File "C:\LynxApps\Python31\lib\logging\handlers.py", line 206, in __init__
t = os.stat(filename)[ST_MTIME]
NameError: global name 'ST_MTIME' is not defined
:
파이썬 V2 ->http://docs.python.org/library/logging.html#timedrotatingfilehandler
을Python v3 ->http://docs.python.org/py3k/library/logging.handlers.html?highlight=logging#timedrotatingfilehandler
아 ... 말이 맞았습니다. 고마워. – LynxLee
예, 3.1.2로 테스트했는데 작동합니다. –
그래, 3.2 작품. – LynxLee