python logging does not work at all

后端 未结 1 1953
渐次进展
渐次进展 2021-02-20 03:41

I am trying to use logging in my small python project. Following the tutorial, I added the code below to my code, but the message wan\'t logged to the file as it was supposed to

1条回答
  •  悲&欢浪女
    2021-02-20 03:55

    You called basicConfig() twice at least; the first time without a filename. Clear the handlers and try again:

    logging.getLogger('').handlers = []
    
    logging.basicConfig(
        filename = "a.log",
        filemode="w",
        level = logging.DEBUG)
    

    0 讨论(0)
提交回复
热议问题