PHP code example of mimmi20 / monolog-laminas-factory

1. Go to this page and download the library: Download mimmi20/monolog-laminas-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/ */

    

mimmi20 / monolog-laminas-factory example snippets



return [
    'log' => [
        \Laminas\Log\Logger::class => [
            'name' => 'name',
            'exceptionhandler' => false,
            'errorhandler' => false,
            'shutdownhandler' => false,
            'writers' => [], // Writers for Laminas Log
            'processors' => [], // Processors for Laminas Log
            'handlers' => [ // Handlers for Monolog
                // At the bare minimum you must ' => 'stream',
                    'enabled' => false,
                    'options' => [
                        'stream' => '/var/log/someother-log-file.txt',
                    ],
                ],
            ],
            'monolog_processors' => [], // Processors for Monolog
        ],
    ],
];



return [
    'log' => [
        \Laminas\Log\Logger::class => [
            'name' => 'name',
            'handlers' => [
                'default' => [
                    'type' => 'stream',
                    'options' => [
                        'stream' => '/var/log/some-log-file.txt',
                    ],
                ],
            ],
        ],
    ],
];



return [
    
    'log' => [
        \Laminas\Log\Logger::class => [
            'name' => 'name',
            'handlers' => [
                'default' => [
                    // A Handler type or pre-configured service from the container
                    'type' => 'stream',
                    
                    // Handler specific options.  See handlers below
                    'options' => [
                        'stream' => '/tmp/log_one.txt',
                    
                        // Optional: Formatter for the handler.
                        'formatter' => [
                            'type' => 'line',
                                
                            // formatter specific options.  See formatters below
                            'options' => [], 
                        ], 
                        
                        // Optional: Processor for the handler
                        'processors' => [
                            [
                                // A processor type or pre-configured service from the container
                                'type' => 'psrLogMessage',
                                
                                // processor specific options.  See processors below
                                'options' => [], 
                            ],
                        ],
                    ], 
                ],
            ],
            
            // Processors for Monolog/Logger
            'monolog_processors' => [
                // Array Keys are the names used for the processors
                'processorOne' => [
                    // A processor type or pre-configured service from the container
                    'type' => 'psrLogMessage',
                    
                    // processor specific options.  See processors below
                    'options' => [], 
                ],        
            ],
        ],
    ],
];