Fast and easy way to send Apache logs to syslog
I keep forgetting how to do this and have to look it up every time, so I'm writing it down.
If you want to send Apache logs to syslog, it really is simple. I'm talking about RHEL/CentOS/Fedora servers with standard packages installed. Follow these simple steps:
In your Apache config where you set CustomLog, make that line look something like this:
CustomLog "|/bin/logger -p local1.info -t apache" combined
ErrorLog syslog:local1
Let's break this down and explain it....
The secret is a program on your server /bin/logger which allows you to pipe anything to syslog. You just need to define a which facility to log. In my example I'm using local1.
The other step is to make sure that /etc/syslog.conf (or whatever your syslog program config is), is handling the right facility as apache.
Here is what I add to my syslog.conf
# apache local1.info /var/log/httpd/apache.log local1.!info /var/log/httpd/error.log
That should be it. Restart httpd and syslog and you should see your apache logs coming through.