Phoenix Phoenix - 4 months ago 29
Apache Configuration Question

Django Logging error

I am using the default logger in Django in
like this.

import logging
logging.basicConfig(filename='models.log',level=logging.INFO)'Staring execution. Models for db tables')

It is working in the Django server and logs are getting written. When the app is being deployed on Apache, I get a
500 Internal Server error
and cannot even load the home page.

The OS is RHEL7. I have changed the file permission of "models.log" to read-write". Still I face the issue. In apache conf file, I have granted permissions as well.


It's problem related with SELinux. If You run locally, then You have full rights to write to log file.

If You run server with apache, then apache must have full rights to write to file.

To check it, login as apache sudo su - apache and try to access to log file.

Solution is simple: put log file in /var/log folder. Or create /var/log/myapp folder and give it full access chmod 777 /var/log/myapp.

import logging
logging.basicConfig(filename='/var/log/myapp/models.log',level=logging.INFO)'Staring execution. Models for db tables')