import os
import time
from loguru import logger
basedir = os.getcwd()
log_path = os.path.join(basedir, 'logs')
if not os.path.exists(log_path):
os.mkdir(log_path)
log_path_all = os.path.join(log_path, f'{time.strftime("%Y-%m-%d")}_log.log')
logger.add(log_path_all, rotation="12:00", retention="20 days", enqueue=True)
Normally, my logs folder should be a log file named by day, like: "2022-09-30_log.log"etc
However, such files appear in the directory: ”2022-09-30_log.2022-10-08_08-25-19_710893.log“
And the content recorded in it is another day's log。Like:
The trailing date indicates Loguru find a file named "2022-09-30_Log.log" which already exists, so it renamed it first to avoid overwriting it. This behavior happens during rotation.
hello,my code is:
Normally, my logs folder should be a log file named by day, like: "2022-09-30_log.log"etc However, such files appear in the directory: ”2022-09-30_log.2022-10-08_08-25-19_710893.log“ And the content recorded in it is another day's log。Like:
So,How to solve this situation?Thanks~