Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do print statements write to when using django + nginx + flup?

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!

like image 696
jmetz Avatar asked Nov 17 '12 03:11

jmetz


1 Answers

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.

like image 144
slumtrimpet Avatar answered Oct 11 '22 14:10

slumtrimpet