【python笔记-5】logging模块切割日志时:另一个程序正在使用此文件,进程无法访问。

发布时间 2023-05-22 10:12:35作者: 偷月

使用:   concurrent-log-handler

GITHUB:   https://github.com/Preston-Landers/concurrent-log-handler

安装: pip install concurrent-log-handler

import logging
from concurrent_log_handler import ConcurrentRotatingFileHandler

logger = logging.getLogger(__name__)
handler = ConcurrentRotatingFileHandler(filename=log_file, mode="a", maxBytes=10 * 1024, 
                        backupCount=5,encoding='utf-8') logger.addHandler(handler)

 

参考文章:python logging模块“另一个程序正在使用此文件,进程无法访问。”问题解决办法-百度网盘下载-Java自学者论坛 - Powered by Discuz! (javazxz.com)