分開我有一個應用程序的CherryPy並啓用日誌記錄(接入和應用程序文件)。記錄從CherryPy的記錄
conf = {'/':
{
'tools.staticdir.on': True,
'tools.staticdir.dir': WEB_ROOT,
'tools.staticdir.index': 'debug_registers2.html',
'log.access_file': ACCESS_LOG,
'log.error_file': APP_LOG,
}
}
除了默認CherryPy的日誌數據,我也使用像語句:
cherrypy.log("My text here")
現在我需要創建一個3日誌文件,我將一些其他的數據傳遞給。 如果我做的:
logging.basicConfig(filename=SPI_LOG,level=logging.DEBUG)
logging.debug('This message should go to the SPI log file')
我CherryPy的日誌數據也進入 「SPI_LOG」 文件。
我如何保持兩個獨立的?
只需在文件頂部設置'logging.getLogger(「cherrypy」)。propagate = False'就不會在屏幕上看到cherrypy日誌。 有關演示,請參閱:https://github.com/cherrypy/cherrypy/issues/1566#issuecomment-296993493 –