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.
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.
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