LogPipe is a PHP extension module that extends the default PHP error messages with additional information and allows you to pipe the logs to an external program or write them to a syslog facility.

When a user connects to a PHP website hosted on a cloud platform like vCluster, the response may come from different web servers running on different virtual and physical machines. This introduced the problem of needing to aggregate the PHP error logs from different cluster nodes and then split them up again based on the virtual host. Unfortunately the default PHP error message handler does not provide the information or ability to pipe the error logs to an external program, unlike the CustomLog directive in Apache does.

vCluster LogoThe vCluster platform provides automatically scalable cloud hosting starting at just £5 per month. Find out more

Here at CatN, we have already solved the problem of web log file processing on the cloud using TCPWebLog but the default PHP error handling does not provide enough information to feed this system, nor does it allow logs to be directly piped into it.

In order to overcome these issues I decided to create LogPipe, an Open Source PHP extension module. Once loaded, when a PHP error is triggered, LogPipe prefixes the error message with the IP and hostname of the virtual host. It then adds the IP of the client before piping the output to and external program (i.e. TCPWebLog) or sending it to a syslog facility. Then the default PHP error handler is called.

The new LogPipe PHP error log format is:



  • VHOST_IP : ($_SERVER['SERVER_ADDR']) the IP address of the server (virtual host) under which the current script is executing.
  • VHOST_NAME : ($_SERVER['HTTP_HOST']) the host name of the server (virtual host) under which the current script is executing.
  • CLIENT_IP : ($_SERVER['REMOTE_ADDR']) the client IP address.
  • LOG_TIME_STR: log date-time.
  • ERROR_TYPE_DESC: type of error.
  • ERROR_DESC: error description.
  • ERROR_FILENAME: the current php script file name were the error originated.
  • ERROR_LINENO: number of the line on the current php script file were the error originated.

For example: example.com [10-Apr-2013 12:34:56] PHP Notice:  Undefined variable: x in /var/www/test.php on line 6 [client]


Before you start, make sure you have the PHP development package installed in your system:
on RHEL-like systems:

yum install php-devel

on Debian-like systems:

sudo apt-get install php5-dev

Note: on the examples below the file paths are relative to a RHEL Operating System, so they may vary depending by the OS you are using.

1. get the LogPipe source code:

cd ~
git clone git://github.com/fubralimited/LogPipe.git

2. compile the LogPipe module:

cd ~/LogPipe
./configure --enable-logpipe

3. copy the LogPipe module on the PHP module directory:

cp ./modules/logpipe.so /usr/lib64/php/modules/

4. copy and edit the LogPipe configuration INI file:

cp logpipe.ini /etc/php.d/
vi /etc/php.d/logpipe.ini

Configuration examples:

disable the module:


send logs to syslog:


pipe logs to TCPWebLog:

; TCPWEBLOG (check the TCPWebLog documentation for the correct parameters)
logpipe.command="/usr/bin/tcpweblog_client.bin 9940 /var/log/tcpweblog_cache.log php.log 1 - -"

The PHP reporting level can be set as usual using the php.ini directive error_reporting.

5. Restart syslog-ng (only if you are using the syslog mode):

service syslog-ng restart

6. Restart Apache:

apachectl restart
WordPress BoxedThe vCluster PHP hosting platform is perfect for WordPress and other bespoke PHP applications.Read more

For additional information on this project please visit the LogPipe project on GitHub repository.
Feel free to try this extension module and leave your comments and suggestions here to help develop the project further.

Nicola Asuni Systems Engineer

Nicola focused on designing, building and integrating the backend for our application platforms, including automatic deployment, monitoring and backups.