问题
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