We help IT Professionals succeed at work.
Get Started

Send all Apache logs to remote syslog server

5,407 Views
Last Modified: 2013-12-16
Due to security needs, we need to send all Access and Error Apache logs from the Apache web server over to our remote Syslog-ng server. So far I have gotten the ErrorLog portion to work via "ErrorLog syslog:local1" entry in the nss.conf file to post at the remote syslog-ng server. However, when I try to pass the Access and TransferLog data to the local syslog server via a perl script, it seems to never get there. The perl-Sys-Syslog RPM has been installed on the client RHEL server.

This is what is seen in the nss.conf file:

LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vcombined
CustomLog |/etc/httpd/bin/apache_syslog vcombined
TransferLog "|/etc/httpd/bin/apache_syslog vcombined"


This is the example 'access' log data that is seen on the local server _which_ that needs to get recorded over on the remote syslog server:

10.153.13.96 - - [09/Jun/2010:14:50:58 -0400] "GET /assets/js/jquery-1.4.2.min.js HTTP/1.1" 200 72174

I have added the code snippet below of the actual 'logging' script I am using to capture the AccessLog and TransferLog data.


In the /etc/syslog.conf file, I have the following entry for accessing our remote syslog-ng server (it works for errors, just not the rest):

local1.* @10.153.13.117

#!/usr/bin/perl

use Sys::Syslog qw( :DEFAULT setlogsock );

setlogsock('unix');
openlog('apache-access', 'cons', 'pid', 'local1');

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

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE