L
L
Lyokha2020-01-17 12:18:13
Django
Lyokha, 2020-01-17 12:18:13

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.
5e217b65b6ef2262696890.jpeg
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)

The logger is used in only one function, which sends a request to api.telegram.org.
logger.info(response)
Kindly tell me how to fix this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-01-17
@bacon

This is not in django, but in logging, more precisely, RotatingFileHandler has a problem with rotate in a competitive environment, use concurrent-log-handler or similar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question