📜  python 记录器异常 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:06.282000             🧑  作者: Mango

代码示例1
# Get Python error information with debug output
# logger.exception outputs a stack trace alongside the error message.

# Example

import logging
try:
    1/0
except ZeroDivisionError:
    logging.exception("error_log")
    
# Outputs
    
ERROR:root:error_log
Traceback (most recent call last):
  File "", line 2, in 
ZeroDivisionError: integer division or modulo by zero