Apache 2.4 Error Log entries incomplete

末鹿安然 提交于 2020-01-07 03:46:08

问题


I am trying to configure Apache 2.4 to include log ID (%L) and remote client IP(%a) into the error.log entries so that I can correlate log entries from multiple log files. It works for every log entry, but not for the most important one - mod_wsgi (my Django app)

This is the logging conf. from Virtual Host

LogLevel debug

ErrorLogFormat "[LogID %-L] [Remote IP %-a] [%-m:%l] [pid %P:tid %T] %M% ,\   referer\ %{Referer}i"
ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined
CustomLog "/var/log/apache2/forensic.log" mylog

This is the error.log output

[LogID -] [Remote IP -] [wsgi:error] [pid 24298:tid 140284674643712][04/Aug/2016 14:50:38] [myapp:common:66] INFO -- Some info message
[LogID wYeHZQ5DK5k] [Remote IP <SHOWN_HERE>:58713] [deflate:debug] [pid 24300:tid 140284649465600] AH01384: Zlib: Compressed 12502 to 3121 : URL /, referer http://myapp.com/

So the problem is that the LogId and Remote (client) IP are not shown for any log entry comming from wsgi, but as you can see in the second line it works for other modules....

Any help is appreciated!

UPDATE:

Here is the wsgi.py

import os

from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
application = get_wsgi_application()

来源:https://stackoverflow.com/questions/38767989/apache-2-4-error-log-entries-incomplete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!