bankiru / monolog-logstash
Monolog Logstash - logging to Logstash
Installs: 8 502
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.0
- ekho/lumberjack-php: ~0.1
- monolog/monolog: ~1.12
Requires (Dev)
- fabpot/php-cs-fixer: ~1.5
- phpunit/phpcov: ~2.0
- phpunit/phpunit: ~4.5
- phpunit/phpunit-mock-objects: ~2.3
- satooshi/php-coveralls: ~0.6
Suggests
- ext-zmq: Required for ZMQHandler
README
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);