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/LongTail_send_access_to_syslog.pl combined

Run this command to load the right Perl module

cpan Sys::Syslog

Then create this file and make it executable: LongTail_send_access_to_syslog.pl

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

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s