apache2.4.7 not logging “404 Not Found” pages to error.log

混江龙づ霸主 提交于 2020-01-15 02:45:57

问题


I've seen questions about how to not log 404 errors to the error log, this is the opposite.

For some reason my apache installation does not log 404 errors to my error log (or to my access log for that matter). I have set the error log properly and see errors going to it, but when I access non-existent pages I simply get my 404 error - the access (but not the 404 error) shows up in the access.log, but I don't see anything in the error log (which makes it hard, for example, to debug why some pages aren't showing up).

My apache (2.4.7) conf settings regarding logs (in the order they are set) are:

ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog logs/error_log
LogLevel warn  # Though I've tried setting this to debug
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"" common
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
CustomLog logs/access_log common
LogFormat "%{HOST}i %h %l %u %t \"%r\" %s %b \"%{User-Agent}i\"" vcommon
CustomLog logs/access_log vcommon

So the only ones that I think are relevant to error log (ignoring overwritten settings) are:

ErrorLog logs/error_log
LogLevel warn  # Though I've tried setting this to debug

回答1:


Finally figured this out.

LogLevel needs to be set to something like 'info' - for some reason the LogLevel of 'warn' which use to log 404 errors no longer does so.

I don't know if 'debug' would work, my question implies that it wouldn't, but I also realized that I had LogLevel set in two places.




回答2:


Good question I'm not sure how to configure apache to do this. Usually to find my errors I just search my access log. You can do this with grep or awk. A really basic command to try is:

grep ' 404 ' access.log


来源:https://stackoverflow.com/questions/29324957/apache2-4-7-not-logging-404-not-found-pages-to-error-log

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