How to use piped logger for flexible logging

A piped logger is a standalone application that receives access log data sent by web server through a pipe on its STDIN stream. This makes flexible logging possible, like logging into a database or logging to remote server.

A piped logger example

Here is a simple piped logger written in Perl, which receives logging data from STDIN and append data received to a file on local harddisk:

open LOG, '>> ../logs/pipedaccess.log';
select LOG;
$| = 1;
while (<>)
   print LOG $_;

To use a piped logger, first, you need to define an external application with type “Piped Logger”, then go to “Access Log” configuration and select the “Piped logger” from the drop down list. Once a piped logger is set, access log data will be sending to the logger application instead of the access log file.

Logging through syslog

You can configure LSWS to use syslog, logging access to syslog.

First, add the following line to your /etc/syslog.conf file: /var/log/lsws_access_log

Then create a logger application with path like this:

/usr/bin/logger -p 

syslogd is pretty slow, it may not be the best solution for a busy server

Logging to remote server through syslog

To log to remote server via syslog, you only need to change the syslog configuration in above example to:  @ip_or_hostname_of_remote_server

Using syslog-ng

syslog_ng is a good replacement for syslogd. Here is toturial on Building a Secure Logging Server With syslog-ng

litespeed_wiki/piped_logger.txt · Last modified: 2006/12/05 12:22 (external edit)