-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
I have written a code that would rotate logs on midnight maintaing backup of 1 day. But the next day, the previous logs are getting deleted.
For example :
While I am checking logs on 14th Feb, I noticed that all the logs generated on 13th Feb, got deleted from instancelogs.log.2025-02-13. The first log generated on 14th Feb is getting stored in instancelogs.log.2025-02-13 file instead of instancelogs.log file , the remaining logs for 14th Feb are correctly stored in instancelogs.log file.
Please look into the issue as we are losing all the logs for 13th of Feb.
I am using below code to handle logs:
import logging
from logging.handlers import TimedRotatingFileHandler
#logger instances for PPT creator
LOG_FILE_PATH = "../STORE_LOGS/instancelogs.log"
instance_logger = logging.getLogger('instance_logger')
instance_logger_file_handler = None
instance_logger_file_handler = TimedRotatingFileHandler(LOG_FILE_PATH, when='midnight', interval=1, backupCount=1)
instance_logger_file_formatter = logging.Formatter(
fmt="[%(asctime)s] - [%(levelname)s] - [%(filename)s] - [%(funcName)s] - %(message)s",
datefmt="%d-%m-%y %H:%M:%S")
instance_logger_file_handler.setFormatter(instance_logger_file_formatter)
instance_logger.setLevel(logging.DEBUG)
instance_logger.addHandler(instance_logger_file_handler)
CPython versions tested on:
3.9
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status