Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (24 sloc) 907 Bytes

Sockets Handler

This handler allows you to write your logs to sockets using fsockopen or pfsockopen.

Persistent sockets are mainly useful in web environments where you gain some performance not closing/opening the connections between requests.

Basic Example


use Monolog\Logger;
use Monolog\Handler\SocketHandler;

// Create the logger
$logger = new Logger('my_logger');

// Create the handler
$handler = new SocketHandler('unix:///var/log/httpd_app_log.socket');

// Now add the handler
$logger->pushHandler($handler, Logger::DEBUG);

// You can now use your logger
$logger->addInfo('My logger is now ready');

In this example, using syslog-ng, you should see the log on the log server:

cweb1 [2012-02-26 00:12:03] my_logger.INFO: My logger is now ready [] []
Jump to Line
Something went wrong with that request. Please try again.