python logging模塊“另一個程序正在使用此文件,進程無法訪問。”問題解決辦法

在多進程下使用python的logging模塊,經常會遇到“另一個程序正在使用此文件,進程無法訪問。”的錯誤。

解決辦法: https://github.com/Preston-Landers/concurrent-log-handler

pip install concurrent-log-handler To use this module from a logging config file, use a handler entry like this:

  file:
    class: concurrent_log_handler.ConcurrentRotatingFileHandler
    level: DEBUG
    formatter: simple
    filename: ./logs/tornado_proj.log
    encoding: utf8  
Note: you must have a "import concurrent_log_handler" before you call fileConfig(). For more information see http://docs.python.org/lib/logging-config-fileformat.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章