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

250
Visualizações
Where does Django stdout output go when running with nginx and Gunicorn?

In my my_application/settings.py file, for example, I have a couple of print statements, thus:

print( 'running settings.py: ALLOWED_HOSTS: ' )
print( '\n'.join( ALLOWED_HOSTS ) )

... where does this output actually go on a remote server running nginx and Gunicorn?

NB I am aware this may be an egregious security breach to print ALLOWED_HOSTS anywhere, for all I know. This is merely an example: I am at the learning/experimentation stage.

Edit after AKX's answer
I found no way of getting stdout to be directed to journalctl, even with the -R switch.

... after many experiments and frustrations and baffling 502 errors, I finally found a way: my systemd config file now looks like this:

[Unit]
Description=Gunicorn server for mysite.xyz

[Service]
Restart=on-failure
User=mike
WorkingDirectory=/home/mike/sites/mysite.xyz
EnvironmentFile=/home/mike/sites/mysite.xyz/.env

ExecStart=/home/mike/sites/mysite.xyz/virtualenv/bin/gunicorn \
    --bind unix:/tmp/mysite.xyz.socket \
    -R \
    --capture-output \
    --error-logfile /home/mike/gunicorn-error.log \
    superlists.wsgi:application

[Install]
WantedBy=multi-user.target

... indeed, I find that it is not sufficient to include the -R switch: you also seem to have to include the --capture-output switch and the --error-logfile switch (NB I am not clear whether there is a default destination for error output if you don't set that switch).

With the above config file, stdout from settings.py goes to the file ~/gunicorn-error.log. Hurrah.

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

0

Wherever gunicorn's stdout is directed to.

If you run things under systemd, for instance, they'll end up into the system journal which you can read with journalctl.

over 4 years ago · Santiago Trujillo Relatório

0

When you run gunicorn there is special parameter named --access-logfile, which specifies the access log file to write to. If you prefer stdout then set the '-' as value parameter. For example:

gunicorn  --access-logfile - demoapp.wsgi
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