1
默認情況下,當我配置如下記錄,刪除日誌級別打印
logging.basicConfig(filename="/tmp/Hom_Controller.log",level=logging.DEBUG)
現在在日誌中我得到如下,
DEBUG:Hom_Controller.log:{'datetime': 'Thu Oct 5 11:27:27 2017', 'message': 'Request finished with error, response code: 401 Unauthorized', 'log_type': 'debug'}
ERROR:Hom_Controller.log:{'datetime': 'Thu Oct 5 11:28:08 2017', 'message': 'Request finished with error, response code: 401 Unauthorized', 'log_type': 'error'}
正如我已經格式化我的消息在json格式中,我不想打印ERROR:Hom_Controller.log:或DEBUG:Hom_Controller.log
請參閱文檔放在這裏格式的日誌輸出:https://docs.python.org/2/library /logging.html#logging.Logger.debug和這裏:https://docs.python.org/2/library/logging.html#logging.Formatter – Bilkokuya