【问题标题】:is there a way to print debug info to the log?有没有办法将调试信息打印到日志中?
【发布时间】:2013-03-30 11:09:52
【问题描述】:

我有一个 python 程序,它可以将一些信息传递给一个站点进行解析。它不工作,但我不知道为什么。有没有办法将诊断信息放在将打印到日志的某些位置?

【问题讨论】:

    标签: python debugging logging


    【解决方案1】:

    您可以使用 python logging 来编写日志文件。

    import logging
    logging.basicConfig(filename='example.log',level=logging.DEBUG)
    logging.debug('This message should go to the log file')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-09
      • 2017-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多