syslog
Apache2.2
Solaris11

HTTPステータス200ではない時のアクセスログをsyslogに出す

More than 1 year has passed since last update.

スクリプトを用意


/var/apache2/2.2/tools/apache_syslog

#!/usr/bin/bash

/usr/gnu/bin/awk " \
/POST/ {
\
if (
\$9 != 200) { \
command = sprintf(
\"echo '%s' | /usr/bin/logger -p local0.error\", \$0);
system(command);
}
\
}
\
{
\
print;
\
} "
| cat >> /var/apache2/2.2/logs/access_log


httpd.confでログ出力設定


httpd.conf

<IfModule log_config_module>

CustomLog "|/var/apache2/2.2/tools/apache_syslog" common
</IfModule>