django + fastcgi + lighttpd outlog and errlog not working

182 views
Skip to first unread message

Gontran Magnat

unread,
Dec 4, 2012, 1:17:59 PM12/4/12
to django...@googlegroups.com
Hello, 

I'm running a django app on lighttpd with fastcgi.
For debugging matters I would need the output logs that usually are displayed on the console.
Because I run my application in a daemonize mode I tried to use the outlog and errlog options but it did not work.

Here is the command I run: 
python manage.py runfcgi method=threaded host=127.0.0.1 port=3033 workdir=/mydir/finderauto_dj/ outlog=out.log errlog=err.log

The out.log and err.log files are created but when I access my website, this should produce this kind of logs:
[03/Dec/2012 23:09:11] "GET /admin/recherches/alert/4/ HTTP/1.1" 200 11844

However, both out.log and err.log files remain empty.

Then I tried to use the daemonize=false option in order to have directly the output: 
python manage.py runfcgi method=threaded host=127.0.0.1 port=3033 daemonize=false

I get nothing either...

Anybody for helping me?

Chris Cogdon

unread,
Dec 4, 2012, 6:49:06 PM12/4/12
to django...@googlegroups.com
I believe you only get the per-request logs when you're running the development server (runserver). When you're running in fastcgi mode (and its been a while since I have), you'll only get entries in outlog and errlog if you actually send stuff to stdout and stderr yourself. And THAT will require fiddling with the LOGGING settings.
Message has been deleted

Tom Evans

unread,
Dec 5, 2012, 7:12:03 AM12/5/12
to django...@googlegroups.com
On Wed, Dec 5, 2012 at 6:44 AM, Gontran Magnat <gontran...@gmail.com> wrote:
> So you mean there is no way to get this kind of log with fastcgi mode:
>

There is always a way, it just doesn't do it by default. If you
require this output even in fastcgi mode than you can create a trivial
middleware to print this output to whatever log you want.

Normally, people use the logging facilities of whatever is hosting the
fastcgi app to create a request log, eg Apache or nginx.

Cheers

Tom

Chris Cogdon

unread,
Dec 5, 2012, 3:49:57 PM12/5/12
to django...@googlegroups.com
Another way would be to set up a receiver for a signal, emit a message via the logging module, configure LOGGING to log those messages to stderr.

Question for others: Is there a good document on what signals django sends?

Since I have it available, here's how you would adjust the LOGGING setting to send all messages up to the DEBUG level to stderr:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console': {
                'level': 'DEBUG',
                'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        '': {
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    }
}


I added the 'console' handler and the '' (empty string) logger as differences from the default.

Of course, if you want to make your signal receiver send to a different logger name (eg: "request"), you only then have to have a logger for that:

        'request': {
            'handlers': ['console'],
            'level': 'INFO',
            'propagate': True,
        },


I dont have sample code for setting up the signal receiver, nor which signal to receive even, handy. Perhaps someone else could help, there?
Reply all
Reply to author
Forward
0 new messages