Just a quick note, since this didn’t immediately come up in a Google search.

Say you have yourself an Apache 2 server on Unix (naturally), but you’d like the logs to end up on a remote machine, for any number of reasons (security, backup, just plain having all your logs in one place, what have you). So you set up rsyslogd on your log machine, set up syslog on your web servers to point to it… and you get nothing from Apache. Apache doesn’t go through syslog by default, writing its own log files instead.

The solution for Apache’s error logs is obvious enough: just add “ErrorLog syslog” to your config file. But mysteriously, there’s no analogous directive for the access logs. The solution is still straightforward enough, and it looks like:

CustomLog "|/usr/bin/logger -p local1.info -t apache2" common

I suppose this shouldn’t seem shocking, but when we were looking this up, many people seemed to forget that (a) the “logger” program exists already, and (b) you can pass options to it directly from the Apache config file, without an intermediate script. In other words, there’s no need at all to be writing additional scripts, which you might not have known based on the Google results I was getting earlier.

Leave a Reply

Your email address will not be published. Required fields are marked *