내 앱에서 로깅 모듈을 사용하고있는 문제가 있습니다. 저는 제 맥북 프로에서 파이썬이 아닌 LDT 파이썬 (Py 2.7) 인터페이스에 대해 이클립스에서 일하고 있습니다. 로깅 모듈은 Eclipse를 통해 작동합니다. 그러나 RHEL5 2.7로 응용 프로그램을 전송할 때 로깅이 전혀 작동하지 않는 것 같습니다. 어떤 예외도 발생시키지 않고 콘솔이나 파일에 아무것도 로깅하지 않습니다 (파일을 생성합니다).Python 로깅 모듈은 Mac에서는 로그인하지만 Linux에서는 로그인하지 않습니다.
코드 :
내가이 일을 할 수있는 방법에 대한 모든 포인터# Initialize logging
log = logging.getLogger('pepPrep')
# Log to stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# Log to file
logname = 'pepPrep.' + datetime.datetime.now().strftime("%Y%m%d_%H:%M") + '.log'
filelog = logging.FileHandler(logname)
filelog.setLevel(logging.DEBUG)
# set a format
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
filelog.setFormatter(formatter)
# add the handler to the root logger
log.addHandler(console)
log.addHandler(filelog)
log.INFO('This is a test')
log.DEBUG('This is a test2')
?
로그를 제대로 닫고 있습니까? – ismail