bankiru/monolog-logstash

This package is abandoned and no longer maintained. No replacement package was suggested.

Monolog Logstash - logging to Logstash

0.1.8 2015-03-10 16:02 UTC

This package is not auto-updated.

Last update: 2022-11-07 16:07:47 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Installing

Composer

"require": {
  "bankiru/monolog-logstash": "~0.1.0"
}

Github

Releases available on Github.

Documentation

Currently implemented:

ZMQ transport

<?php

use Bankiru\MonologLogstash\ZMQHandler;
use Monolog\Formatter\JsonFormatter;

$zmqHandler = new ZMQHandler(
    'tcp://127.0.0.1:2120', // dsn
     true,                  // persistent
     [],                    // ZMQContext options (http://php.net/manual/en/zmqcontext.setopt.php)
     \ZMQ::SOCKET_PUSH,     // ZMQSocket type
     [],                    // ZMQSocket options (http://php.net/manual/en/zmqsocket.setopt.php)
     Logger::INFO,          // log level
     true                   // bubble
);

$zmqHandler->setFormatter(new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES)); // optional but recommended

$log = new Logger('name');
$log->pushHandler($zmqHandler);

Lumberjack transport

<?php

use Bankiru\MonologLogstash\LumberjackHandler;
use Bankiru\MonologLogstash\LumberjackFormatter;
use Ekho\Logstash\Lumberjack;

$lumberjackHandler = new LumberjackHandler(Logger::INFO, true);
$lumberjackHandler->init(
    '127.0.0.1',
    2323,
    'path/to/certificate.crt',
    [
        'window_size' => 5000,
    ]
);
$lumberjackHandler->setFormatter(new LumberjackFormatter('my_app_name'));

$log = new Logger('name');
$log->pushHandler($lumberjackHandler);