I am using python logging.handlers.RotatingFileHandler for my log rotation. It is working fine and writting logs to let's say app.log file but after the first rotation it doesn't write to the app.log file all the time. sometimes it start writting to app.log.1 or any other file like that and also it rotates the file too early even though the max byte has not reached. The correct behaviour should be to write to the app.log file alawys. And i want that behaviour only. I have multiple module and every module write to a separate file. Every module use the below method to get its logger by passing log_name and log_file_name.
def get_logger(log_name, log_filename): log = logging.getLogger(log_name) logs_file = os.path.join(log_path, log_filename) log.setLevel(logging.DEBUG) file_formatter = logging.Formatter('%(asctime)s - %(pathname)s - %(levelname)s - %(message)s') file_handler = logging.handlers.RotatingFileHandler(logs_file, maxBytes=int(1.5e7), backupCount=15) file_handler.setFormatter(file_formatter) file_handler.setLevel(logging.DEBUG) log.addHandler(file_handler) return logIf anyone have face this kind of issue, what solution did you apply.