Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 152010
 

Sending Apache log to syslog?

Answer:

In the Apache config (httpd.conf), add/modify the followings as needed

1. For Access log

CustomLog |/usr/local/apache/bin/apache_syslog combined

Where apache_syslog is a Perl script


#!/usr/bin/perl
use Sys::Syslog qw( :DEFAULT setlogsock );

setlogsock('unix');
openlog('apache', 'cons', 'pid', 'local2');

while ($log = ) {
            syslog('notice', $log);
}
closelog

2. For Error log

Apache already has direct support error log to syslog, so just add the target syslog facility.

ErrorLog syslog:local1

This tells Apache to send the error log output to the syslog facility local1

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>