I just set up new server and while I'm checking it, I got 500 error. I expect that debug.log file has error message, However, when I check the file the file was empty. Nothing was written. So I changed the loggers settings may times, but still the file is empty and I can't fix the error because what is wrong with it...
This is my views.py
logger = logging.getLogger(__name__)
put this line to do logging.
settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'format': '%(asctime)s %(filename)s:%(lineno)d %(message)s',
}
},
'handlers': {
'file': {
'level': 'DEBUG',
'filters': ['require_debug_false'],
'class': 'logging.handlers.RotatingFileHandler',
'filename': '/var/log/service/debug.log',
'formatter': 'simple',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'ERROR',
'propagate': True,
},
}
}
if DEBUG:
del LOGGING['loggers']['django']
del LOGGING['handlers']['file']
if not os.path.exists('log'):
os.makedirs('log')
I attached my wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
application = get_wsgi_application()
This is settings.py where import local settings.
try:
from local_settings import *
except ImportError:
raise ImportError('You must create local_settings.py on project root')
This is local_settings.py
DEBUG=False