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


Try sending all of ErrorLog to a pipe, for example a perl script. This perl script could direct to syslog and the local disk.

| improve this answer | |

You can use:

ErrorLog "| tee -a /var/log/httpd/error_log | /usr/bin/logger -t httpd -i -p local4.error"

to do what you are after.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.