PHP code example of nikolaposa / monolog-factory
1. Go to this page and download the library: Download nikolaposa/monolog-factory 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/ */
nikolaposa / monolog-factory example snippets
use Monolog\Formatter\HtmlFormatter;
use Monolog\Handler\BufferHandler;
use Monolog\Handler\NativeMailerHandler;
use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use MonologFactory\DiContainerLoggerFactory;
return [
'logger' => [
'logger1' => [
'name' => 'logger1',
'handlers' => [
[
'name' => NativeMailerHandler::class,
'params' => [
'to' => '[email protected] ',
'subject' => 'Test',
'from' => '[email protected] ',
'level' => Logger::ALERT,
],
'formatter' => [
'name' => HtmlFormatter::class,
],
],
],
'processors' => [
[
'name' => PsrLogMessageProcessor::class,
],
],
],
'logger2' => [
'name' => 'logger2',
'handlers' => [
[
'name' => BufferHandler::class,
'params' => [
'handler' => [
'__class__' => NativeMailerHandler::class,
'to' => '[email protected] ',
'subject' => 'Test',
'from' => '[email protected] ',
],
'buffer_limit' => 5,
],
'processors' => [
[
'name' => MemoryUsageProcessor::class,
],
],
],
],
'processors' => [
[
'name' => PsrLogMessageProcessor::class,
],
],
],
],
'di' => [
'factories' => [
'Logger1' => new DiContainerLoggerFactory('logger1'),
//... or more preferred/optimal way:
'Logger2' => [DiContainerLoggerFactory::class, 'logger2'],
],
],
];