Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!