在多進程下使用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