LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Redirecting Apache/Tomcat Logs to rsyslog without writing to disk.... (https://www.linuxquestions.org/questions/linux-software-2/redirecting-apache-tomcat-logs-to-rsyslog-without-writing-to-disk-883063/)

elorson 05-27-2011 12:03 PM

Redirecting Apache/Tomcat Logs to rsyslog without writing to disk....
 
For internal security reasons I need to prevent our tomcat logs from writing to the webserver local disk. We set up a separate logging server with rsyslog and need to pipe the log data to it.

I am trying to work out how to configure tomcat to send all log data to the logging server via the rsyslog client (running locally) via a named pipe.

We are on CentOS 5.6, Tomcat 6 and rsyslog 5.8.1.

I need to know:
1) do we use the default logging library or log4j
2) where is this configured in the tomcat config
3) is there any code that would need to be written to achieve this

Thanks,
Eric

vkvs 05-28-2011 11:56 PM

Thats how I currently have it set: apache writes to a regular log file, sends a copy to rsyslog, rsyslog sends it to remote server.

How to set:

In vhosts directive:
Code:

CustomLog |/usr/bin/apache_syslog syslog
ErrorLog |/usr/bin/apache_syslog

/usr/bin/apache_syslog:
Code:

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

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

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


Of course this requires syslog defined in apache, or use common/combined. Enjoy!


All times are GMT -5. The time now is 01:38 PM.