Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
1  
Something like this well-known Perl script, for example: oreillynet.com/pub/a/sysadmin/2006/10/12/httpd-syslog.html –  Stefan Lasiewski May 2 '12 at 20:11
    
Send it to whatever priority is already configured in your syslog.conf, and also open your log file and write $log there too. –  Sirch May 2 '12 at 20:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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