Apache httpd: Send error logs to syslog and local disk? Without touching /etc/syslog.conf?

Posted by Stefan Lasiewski on Server Fault See other posts from Server Fault or by Stefan Lasiewski
Published on 2012-05-02T18:55:41Z Indexed on 2014/05/27 21:36 UTC
Read the original article Hit count: 262

I have an Apache httpd 2.2 server. I want to log all messages using syslog, so that the requests are sent to our central syslog server. I also want to ensure that all log messages are sent to local disk, so that a sysadmin can have easy access to the log files on the local system.

It is easy to send HTTP access logs to both the local disk and to syslog. One common method is:

LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/access_log combined
CustomLog "|/usr/bin/logger -t httpd -i -p local4.info" combined

But it is not easy to do this for error logs. The following configuration doesn't work, because the error logs only use the last ErrorLog stanza. The first ErrorLog stanza is ignored.

ErrorLog logs/error_log
ErrorLog syslog:local4.error

How can I ensure that Apache errors logs are written to the local disk and are sent to syslog?

Is it possible to do this without touching /etc/syslog.conf ? I am fine if my users want to manage their own Apache configuration files, but I do not want them touching system files such as /etc/syslog.conf

© Server Fault or respective owner

Related posts about apache-2.2

Related posts about security