Answer the question
In order to leave comments, you need to log in
Why is Django splitting logs into different files?
Hello.
Jambs with logging began. Suddenly, instead of writing logs to one file bot.log, they began to be written to different files bot.log.1, bot.log.2, bot.log.3, etc.
I calculated that this starts happening when the file reaches its maximum size.
Here is the code.
bytes = 15728640
count = 15
file_log = '../logs/bot.log'
handler = logging.handlers.RotatingFileHandler(file_log, maxBytes=bytes, backupCount=count)
handler.setFormatter(logging.Formatter('%(levelname)-6s %(asctime)s %(message)s', datefmt='%d-%m-%Y %H:%M:%S'))
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
logger.info(response)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question