问题描述
我有一个用例,其中多个进程将记录到同一日志文件。我已经实现了https://docs.python.org/3/howto/logging-cookbook.html#sending-and-receiving-logging-events-across-a-network中所述的基于套接字的日志记录。因此,有一个主要进程可以启动TCP服务器,如上面的链接所述,它会定期运行其他进程,并使用日志套接字服务器将该日志记录到该文件中。我需要旋转文件并进行备份。我尝试使用RotateFileHandler,但无法正常工作。我尝试在以下代码中添加其他处理程序
def setup_rotating_file_handler(logfile,max_bytes,backup_count):
if backup_count is not None and max_bytes is not None:
assert backup_count > 0
assert max_bytes > 0
ch = RotatingFileHandler(logfile,'a',backup_count)
logging.getLogger().addHandler(ch)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)