集中Apache日志中的所有404错误以分离文件(对于所有域)?

除了正常的日志文件(我希望as-well) 之外 ,是否可以将所有域的Apache日志configuration为一个单一的集中式文件。

我甚至更喜欢只有404(访问),所以单个日志文件的所有域和只有404消息(同时保持每个虚拟域中设置的日志文件)?

更新1:访问日志文件

更新2:我正在寻找服务器范围的configuration选项,我不想调整每个configuration。 消息应logging在域访问日志主日志中。

CustomLog指令有一个env=参数,可以在最后添加。 它可以在mod_rewrite的帮助下进行设置。 configuration文件应该包含这样的内容:

 RewriteEngine On # exclude directory index RewriteCond %{REQUEST_URI} !/index\.(php|html?)$ # exlcude auto-index of directories RewriteCond %{REQUEST_URI} !/$ # if the request is not a file, directory, or symlink RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l # set the "notfound" environment variable RewriteRule ^ - [E=notfound:true,L] CustomLog /var/log/apache2/404-requests.log common env=notfound CustomLog /var/log/apache2/requests.log common env=!notfound 

自定义日志文件404-requests.log将仅在未设置环境时logging事件,而日志requests.log将logging其他所有内容。

我把它每个VirtualHost有它自己的日志指令? 如果是这样,他们覆盖任何全球指令。

要拥有全局访问日志,您需要从虚拟主机configuration中删除或修改日志logging指令。