How to send Apache HTTPD access.log to syslog

In the file:/etc/http/conf/httpd.conf

Look for this line

CustomLog logs/access_log combined

And then add this line right after it:

CustomLog |/usr/local/etc/ combined

Run this command to load the right Perl module

cpan Sys::Syslog

Then create this file and make it executable:

    use Sys::Syslog qw( :DEFAULT setlogsock );
openlog('LongTail_apache', 'pid', 'auth');
# I use 'auth' for LongTail, you can choose something else.
while ($log =<STDIN>){
                syslog('notice', $log);

Then restart apache and your access.log logfile will go to syslogg.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s