I am not able to get logging work in production (arch linux). On local machine it works fine. Here are the logging settings:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': 'LEVEL:%(levelname)s TIME:%(asctime)s MODULE:%(module)s LINE:%(lineno)d PROCESS:%(process)d THREAD:%(thread)d MESSAGE:%(message)s'
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'logfile': {
'level':'DEBUG',
'class':'logging.FileHandler',
'filename': "logs/logfile314.txt",
'formatter': 'verbose',
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'myLog': {
'handlers': ['logfile'],
'level': 'DEBUG',
},
}
}
When I deploy this to production I saw this error in apache log:
ValueError: Unable to configure handler 'logfile': [Errno 13] Permission denied: '/srv/http/logs/logfile314.txt'
So I went and fixed permissions on /srv/http/logs
to :
drwxrwxrwx 2 root root 4.0K Aug 21 16:05 logs
Now the application doesn't even start and after 2-3 minutes front page loading breaks and in apache log there is this error:
Fatal Python error: PyEval_AcquireThread: NULL new thread state
[Wed Aug 21 16:05:58 2013] [notice] child pid 32559 exit signal Aborted (6)
[Wed Aug 21 16:11:03 2013] [error] [client 89.142.110.111] Premature end of script headers: wsgi.py
But I haven' changed wsgi.py in a long time. Everything works ok, if I remove my setting for logging or if I gave path to which http user does not have permissions. I tried putting the absolute path to log file, since /srv/http/logs
probaly isn't the right place to put log files, but even this doesn't work.
Any ideas or suggestions how to get logging to work on production also?
I managed to solve the problem by putting this line of code to apache configuration file:
WSGIApplicationGroup %{GLOBAL}
Explanation could be found here: https://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
I have met the same error. I found that if I created a new folder and file, the user-name and group-name are both Apache. The error will be missed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.