6

I'm using apache web server and mod_wsgi to transfer request to django.

$ apache2ctl -v
Server version: Apache/2.4.10 (Raspbian)
Server built:   Sep 17 2016 16:40:43

I'm using this apache site to declare django app:

ServerName example.com
DocumentRoot /srv/webapps/myapp

<Directory /srv/wepapps/myapp/mysite>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess example.com python-path=/srv/webapps/myapp:/usr/local/lib/python3.4/dist-packages:/usr/lib/python3/dist-packages
WSGIProcessGroup example.com
WSGIScriptAlias / /srv/webapps/myapp/mysite/wsgi.py

LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined

It works great, but if an exception is raised, it shows an error 500 but there is nothing in my example.com_error.log. If I modify my settings to set Debug = True, I can see error in my web browser, but in my /var/log/apache2 file too. But I really don't want to keep this setting in my prod environment.

Do you have an idea about why I have to put Debug = True to allow django to write on system logs?

Thanks in advance for your answers, and sorry if I did some mistakes with my english ;-)

1 Answer 1

2

In your settings.py file, you will need to add the following to the LOGGING configuration:

LOGGING = {
    #  ... omitting the formatters and handlers for brevity ...
    'loggers': {
        # ...  you may have other loggers here as well ...
        'django': {
            'handlers': ['name_of_your_file_handler_goes_here'],
            'level': 'DEBUG',
            'propagate': True,
        }
    }

You probably should set the level to ERROR or WARN in production.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .