How to write to a file, using the logging Python module?

后端 未结 9 2054
天涯浪人
天涯浪人 2020-11-27 10:34

How can I use the logging module in Python to write to a file? Every time I try to use it, it just prints out the message.

9条回答
  •  自闭症患者
    2020-11-27 10:49

    import sys
    import logging
    
    from util import reducer_logfile
    logging.basicConfig(filename=reducer_logfile, format='%(message)s',
                        level=logging.INFO, filemode='w')
    

提交回复
热议问题