Skip to content

abacaphiliac/enlite-monolog

This branch is 131 commits behind enlitepro/enlite-monolog:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

85c4881 · May 4, 2015

History

32 Commits
Feb 18, 2014
Apr 28, 2015
Feb 21, 2015
Oct 18, 2013
Dec 5, 2013
Oct 22, 2013
Oct 18, 2013
Feb 28, 2014
Jan 23, 2014
Oct 18, 2013

Repository files navigation

Monolog integration to ZF2 Build Status

Integration to Zend Framework 2 great log system monolog

INSTALL

The recommended way to install is through composer.

{
    "require": {
        "enlitepro/enlite-monolog": "~1.1.0"
    }
}

USAGE

  1. Add EnliteMonolog to your config/application.config.php to enable module.
// usage over service locator
$serviceLocator->get('EnliteMonologService')->addDebug('hello world');

use EnliteMonolog\Service\MonologServiceAwareInterface,
    EnliteMonolog\Service\MonologServiceAwareTrait;

// usage in your services
class MyService implements MonologServiceAwareInterface
{
    use MonologServiceAwareTrait;

    public function whatever()
    {
        $this->getMonologService()->addDebug('hello world');
    }
}
  1. Copy the config file config/monolog.global.php.dist from the module to config/autoload your project.

By default it write logs to data/logs/application.log. If you want change this behaviour, add your config following:

    'EnliteMonolog' => array(
        'EnliteMonologService' => array(
            // Logger name
            // 'name' => 'EnliteMonolog',

            // Handlers, it can be service locator alias(string) or config(array)
            'handlers' => array(
                // by config
                'default' => array(
                    'name' => 'Monolog\Handler\StreamHandler',
                    'args' => array(
                        'path' => 'data/log/application.log',
                        'level' => \Monolog\Logger::DEBUG,
                        'bubble' => true
                    ),
                    'formatter' => array(
                        'name' => 'Monolog\Formatter\LogstashFormatter',
                        'args' => array(
                            'application' => 'My Application',
                        ),
                    ),
                ),

                // by service locator
                'MyMonologHandler'
            )
        ),

        // you can specify another logger
        // for example ChromePHPHandler

        'MyChromeLogger' => array(
            'name' => 'MyName',
            'handlers' => array(
                array(
                    'name' => 'Monolog\Handler\ChromePHPHandler',
                )
            )
        )
    ),

now you can use it

$serviceLocator->get('EnliteMonologService')->addDebug('hello world');
$serviceLocator->get('MyChromeLogger')->addInfo('hello world');

About

Monolog integration to Zend Framework 2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%