问题原文
原帖链接 · Bill · CC BY-SA 3.0
How can i get all 404 errors from all the sites into one log? I only know how to do it on one domain and only when i change the default 404 page.
Here is how i did it on one domain
error_page 404 /404.html;
location = /404.html {
root /home/awesomename;
access_log /home/custom_logs/404.log;
internal;
}
Is there a way to do it without changing anything else?
已采纳解答
原帖链接 · Nomadic · CC BY-SA 3.0
The if parameter (1.7.0+) enables conditional logging. A request will not be logged if the condition evaluates to “0” or an empty string. In the following example, the requests with response codes 4xx will be logged:
map $status $loggable {
~^[4] 1;
default 0;
}
access_log /path/to/access.log combined if=$loggable;
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
