# Set an environment variable for 400 series errors
SetEnvIfNoCase Response_Status "^400" LOG_400_ERRORS
# Define a custom log format that includes the error status
LogFormat "%h %l %u %t \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_status
# Use conditional logging based on the environment variable
CustomLog /tmp/400errors.log combined_with_status env=LOG_400_ERRORS
方法2 - Mod Rewrite
在apache中使用mod_rewrite,无论是在你的站点配置,还是htaccess文件中
RewriteEngine On
# Redirect 400 series errors to a custom error log
RewriteCond %{REQUEST_STATUS} ^400
RewriteRule ^ - [E=LOG_400_ERRORS]
# Define a custom log format that includes the error status
LogFormat "%h %l %u %t \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_status
# Use conditional logging based on the environment variable
CustomLog /tmp/400errors.log combined_with_status env=LOG_400_ERRORS
1条答案
按热度按时间fruv7luv1#
将
/tmp/400errors.log
更改为要记录输出的位置方法1 - SetEnvIf
在apache中使用
SetEnvIf
将此添加到
httpd.conf
方法2 - Mod Rewrite
在apache中使用
mod_rewrite
,无论是在你的站点配置,还是htaccess文件中