How To Use A 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.

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.

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

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

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

  • Admin
  • Last modified: 2015/07/30 18:45
  • by Michael Alegre