wikimart / log4php-graylog2
Log4php appenders and layouts for compatibility with graylog2
Requires
- apache/log4php: >=2.3.0
This package is not auto-updated.
Last update: 2024-12-30 13:09:05 UTC
README
===== About
Copyright (c) 2012-2014 Dmitriy Ulyanov
Here you can find 2 new appenders for log4php: LoggerAppenderAMQP and LoggerAppenderGraylog2. You can pass log messages to Graylog2 or AMQP (RabbitMQ for ex.) using it.
Appender LoggerAppenderGraylog2 can pass messages directly to Graylog2 server. Appender LoggerAppenderAMQP can pass messages to AMQP Server. In this case you can set up yours graylog2 to recieving messages from AMQP.
If you would like to pass messages in GELF format, use special layout: LoggerLayoutGelf
============ Installation
For composer users
- Add to your composer.json:
{ "require": { "wikimart/log4php-graylog2": ">=1.0.0" }, "repositories": [ { "type": "git", "url": "git://github.com/wikimart/log4php-graylog2.git" } ] }
- Run composer.phar update
For other users
- Set up your log4php config file (see exampleConfig.xml)
- Use your new logger:
require 'log4php/Logger.php';
require 'log4php-graylog2/src/main/php/bootstrap.php';
============= Configuration
XML
PHP
array( 'rootLogger' => array( 'appenders' => array('MyAMQPAppender', 'MyGraylog2Appender') ), 'appenders' => array( 'MyAMQPAppender' => array( 'class' => 'LoggerAppenderAMQP', 'params' => array( 'host' => 'example.com', 'port' => 5672, 'vhost' => '/logs', 'login' => 'my_login', 'password' => 'my_secret_password', 'exchangeName' => 'my_exchange', 'routingKey' => 'php_application', 'contentType' => 'application/json' ), 'layout' => array( 'class' => 'LoggerLayoutGelf' ) ), 'MyGraylog2Appender' => array( 'class' => 'LoggerAppenderGraylog2', 'params' => array( 'host' => '192.168.1.123', 'port' => 12201 ), 'layout' => array( 'class' => 'LoggerLayoutGelf' ) ), ), );
===== Usage
Logger::configure('exampleConfig.xml', 'LoggerConfigurationAdapterXML'); $myLogger = Logger::getLogger('MyLogger'); $myLogger->debug("Hello world!");