Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

454
Visualizações
Django - Loggers are overwriting the previous log file along with the new one

I am using Django logger for logging along with gunicorn workers. Currently, I am testing with 3 workers and I am using the TimedRotatingFileHandler. I configured when = m and interval = 1, I tried sending some 1000 requests and it is writing in the new file and overwriting the old file as well.

Here is my config from settings.py

'debug': {
            'level': 'DEBUG',
            'filename': BASE_DIR + '/Log/debug.log',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'when': 'M',
            'interval': 1,
            'formatter': 'verbose'
        },

This will happen only if i use more than 1 gunicorn worker. But if I use 1 gunicorn worker this is not happening.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You shouldn't be using file-based handlers directly from multiple processes concurrently, which is what you get if you use gunicorn with this configuration. Instead, use a SocketHandler or QueueHandler to send logs from the webapp to a separate process which logs them to disk. The Python logging cookbook has more information and example code, which is too long to reproduce here.

Writing to a single file from multiple concurrent processes without them treading on each other isn't supported in Python (and a lot of other languages too).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda