2017-09-05 94 views
0

我很抱歉地問,因爲它不是第一次,但我一直無法通過查看舊帖子來修復它自己。Python日誌記錄,沒有得到任何輸出

我試圖創建和使用python寫入日誌文件。我創建的文件很好,但沒有輸入到我正在創建的文件中。

這裏是我的代碼:

import logging 

log_file = '/home/user/Test.log' 

form = "%(asctime)s - %(levelname)s - %(message)s" 

logging.basicConfig(filename=log_file, filemode='w', level=logging.DEBUG , format=form) 

logging.debug = ('DEBUG MESSAGE!') 
+0

您是否嘗試將日誌記錄級別更改爲更高優先級的日誌級別? –

回答

2

那麼你需要改變:

logging.debug = ('DEBUG MESSAGE!')

logging.debug('DEBUG MESSAGE!')

這樣,它應該工作!

+1

非常感謝! –

+0

@LasseBøg歡迎! – Szabolcs

相關問題