PHP code example of amberovsky / zf2-monolog

1. Go to this page and download the library: Download amberovsky/zf2-monolog library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amberovsky / zf2-monolog example snippets


use Amberovsky\Monolog\Config;
use Monolog\Handler\StreamHandler;
use Formatter;

return [
	'monolog'	=> [
        'root'  => [
            Config::SECTION_HANDLERS    => [
                [
                    Config::HANDLER_CLASS   => StreamHandler::class,
                    Config::HANDLER_ARGS    => [
                        'path'  => '/var/log/root.log',
                    ],
                    
                    config::HANDLER_FORMATTER   => [
                        Config::FORMATTER_CLASS => Formatter::class,
                        Config::FORMATTER_ARGS  => [
                            
                        ]
                    ],
                ],
            ],
        ]
	]
];


use Amberovsky\Monolog\MonologFactoryTrait;

class Whatever {
    use MonologFactoryTrait;
    
    public function action() {
         $this->getMonologFactory()->getLogger('root')->debug('hello');
    }
}