Log all requests to file Django
<p>When I run the django development server (<code>./manage.py runserver</code>) all requested urls are conveniently logged into process stdout, with the precise time and the response code:</p>

<pre><code>[09/Jun/2016 23:35:53] "GET /api/game/ HTTP/1.1" 404 3185
[09/Jun/2016 23:36:01] "GET /api/game/123/ HTTP/1.1" 404 1735
</code></pre>

<p>It is very handy because when analysing output you immediately see the request corresponding to your log messages, for example:</p>

<pre><code>WARNING:2016-06-09 23:41:27,806:views:7449:140139847718656: No such object in the database: u'123'
[09/Jun/2016 23:41:27] "GET /api/game/123/ HTTP/1.1" 404 1735
</code></pre>

<p>I used to work with uwsgi+nginx, so I used 'console' logging handler for everything, and then started uwsgi like this:</p>

<pre><code>exec uwsgi --master --die-on-term --logto /var/log/uwsgi.log
</code></pre>

<p>As a result I got all the necessary logging in <code>/var/log/uwsgi.log</code>, uwsgi's request records and my own logging messages.</p>

<p>Now I want to achieve the same result with Apache+mod WSGI+django. I want the only file to contain all requests and all the logs from my django app in one place.</p>

<p>I've tried to achieve this with Django logging configuration, but even when I redirect django.requests to the same file I get only my own messages in the logs, no requests at all. Here is the portion of the configuration:</p>

<pre><code>'handlers': {
    'file_handler': {
        'level': DEBUG and 'DEBUG' or 'INFO',
        'class': 'logging.handlers.RotatingFileHandler',
        'filename': join(LOG_DIRECTORY, 'api_log.log'),
        'maxBytes': 1024 * 1024 * 5,  # 5 MB
        'backupCount': 15,
        'formatter': 'verbose',
    },
},
'loggers': {
    'api': {
        'handlers': ['file_handler'],
        'level': DEBUG and 'DEBUG' or 'INFO',
    },
    'django': {
        'handlers': ['file_handler'],
        'level': DEBUG and 'DEBUG' or 'INFO',
    },
    'django.request': {
        'handlers': ['file_handler'],
        'level': DEBUG and 'DEBUG' or 'INFO',
    },
    'django.db.backends': {
        'handlers': ['file_handler'],
        'level': DEBUG and 'INFO' or 'WARNING',
        'propagate': False,
    },
}
</code></pre>

<p>Is there a way to achieve nginx+uwsgi+django logging behavior with apache+WSGI+django? Or the only way is to keep apache access.log and my logs in separate files?</p>

<p>I guess in the first case it was development server who logged requests, and in the second case it was uwsgi process. Maybe there's a way to tell WSGIDaemonProcess to do the same?</p>