Django log requests with status 200 to syslog
<p>I am writing a Django Application and using basic URL Routing to views. I am trying to implement logging to syslog. I want to log all incoming requests to syslog. My <code>LOGGING</code> dict looks like this:</p>

<pre><code>LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse',
        },
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
    },
    'formatters': {
        'verbose': {
            'format': '%(process)-5d %(name)s:%(lineno)d %(levelname)s %(message)s'
        },
        'simple': {
            'format': '[%(asctime)s] %(name)s %(levelname)s %(message)s',
            'datefmt': '%d/%b/%Y %H:%M:%S'
        },
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'filters': ['require_debug_true'],
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'syslog': {
            'level': 'DEBUG',
            'class': 'logging.handlers.SysLogHandler',
            'facility': 'local7',
            'address': '/dev/log',
            'formatter': 'verbose'
       },
    },
    'loggers': {
        'django.server': {
            'handlers': ['console', 'syslog'],
            'level': 'INFO',
            'propagate': False
        },
        'my_project': {
            'handlers': ['console', 'syslog'],
            'level': 'INFO',
            'propagate': False,
        },
        # root logger
        '':{
            'handlers': ['console', 'syslog'],
            'level': 'INFO',
            'disabled': False
        },
    },
}
</code></pre>

<p>Whenever I hit any URL on the server, the following is logged into the console:</p>

<pre><code>[01/Oct/2016 18:30:34] "POST /api/v1/users/login/ HTTP/1.1" 200 73
</code></pre>

<p>But nothing in my log file.</p>

<p>When I insert a <code>logger.error('Something went wrong!')</code> in my code, it gets logged in my log file.</p>

<p>How do I get the requests log in my log file?</p>

<p>TIA</p>

<p>The logging requests from django to syslog depends on several things:</p>

<ul>
<li>Syslog configuration. I assume that your syslog configuration is
correct and syslog does not drop debug messages from local7.</li>
<li>If you run your application with 'runserver', django uses built-in lightweight http server. This server logs request messages. Prior to 1.10 it used to log to <strong>sys.stderr</strong> and it was not possible to configure that via LOGGING dict. In django 1.10 this has changed to use python logging mechanism: <a href="https://docs.djangoproject.com/en/1.10/ref/django-admin/#django-admin-runserver" rel="nofollow">https://docs.djangoproject.com/en/1.10/ref/django-admin/#django-admin-runserver</a></li>
<li>If you run your app using nginx+uwsgi for example, logging requests is handled by nginx/uwsgi.</li>
</ul>

python django logging