How to Open Django Error Log File (And Configure)

The log files for your Django application are defined in the file. Let's begin by opening the file which is located in your project's main directory.


nano src/myproject/


Now look for a dictionary called LOGGING. If it isn't in the file, add the following code somewhere appropriate in your file:


   'version': 1,
   'disable_existing_loggers': False,
   'handlers': {
       'file': {
           'level': 'DEBUG',
           'class': 'logging.FileHandler',
           'filename': 'debug.log',
   'loggers': {
       'django': {
           'handlers': ['file'],
           'level': 'DEBUG',
           'propagate': True,


This will create a file called debug.log in the project directory when an error occurs.


If this doesn't work you may need to reload the daemon service and possibly the Web Server Gateway Interface if you are using one. For me the WSGI is Gunicorn.


sudo systemctl daemon-reload
sudo systemctl restart gunicorn


Now you can open the log file with nano:


nano src/debug.log