Idea Farm Casting ideas to the wind to see what takes root

15Nov/110

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.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

* Copy this password:

* Type or paste password here:

1,029 Spam Comments Blocked so far by Spam Free Wordpress

No trackbacks yet.