I'm trying to debug a django app of mine, but it's hard because I have no idea where my print statements are sending their output. I'm using flup and fastcgi with django and nginx, and I can see python errors and access logs via nginx, but I have no idea where my print statements are going.
Here's the relevant stuff from my nginx.conf file:
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/demo.access.log;
error_log /var/log/nginx/demo.error.log;
location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9001;
}
}
And i'm running fastcgi using this command:
python manage.py runfcgi host=127.0.0.1 port=9001
I basically followed this tutorial https://code.djangoproject.com/wiki/DjangoAndNginx and my OS is ubuntu!
Thanks for the help!
I agree with the logging recommendation, but these days the link should point to the integrated Django functionality, not just to the base Python libs.
https://docs.djangoproject.com/en/dev/topics/logging/
With a basic setup and something simple like the following at the top of your Python code:
import logging
log = logging.getLogger(__name__)
You can then do stuff like this in your code:
log.debug('output message')
which will land where you Django logging settings are pointed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With