smartframe-technologies / laminas-monolog-logger
Implementation monolog library using laminas service manager and other libs
Installs: 2 439
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 2
Requires
- php: ^7.4 || ^8.0
- elasticsearch/elasticsearch: ^7.10
- laminas/laminas-diactoros: ^2.5
- laminas/laminas-servicemanager: ^3.5
- monolog/monolog: ^2.1
- psr/container: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2025-02-23 17:24:33 UTC
README
The LaminasMonologLogger
provides integration of the Monolog library into the Laminas framework and Mezzio projects.
Installation
Install the latest version with
$ composer require smartframe-technologies/laminas-monolog-logger
Configuration
Start by creating a logging configuration file (i.e. config/autoload/logger.global.php
) with minimal configration
If are you using ConfigAggregator library already have defined ConfigProvider
More information in ConfigProviders section
Minimal config settings
<?php return [ 'logger' => [ //global processors 'processors' => [], //global handlers 'handlers' => [ Monolog\Handler\StreamHandler::class => [ 'stream' => '/var/log/php.log' ], ], //logger services Monolog\Logger::class => [ 'channel_name' => 'application' //required ] ] ];
Full config settings
<?php declare(strict_types=1); use Monolog\Logger; use Monolog\Processor\HostnameProcessor; use Monolog\Processor\IntrospectionProcessor; use Monolog\Processor\MemoryPeakUsageProcessor; use Monolog\Processor\ProcessIdProcessor; use Monolog\Processor\WebProcessor; use SmartFrame\Logger\Processor\ModuleProcessor; return [ 'logger' => [ //global processors 'processors' => [ MemoryPeakUsageProcessor::class => [], WebProcessor::class => [], IntrospectionProcessor::class => [], ModuleProcessor::class => [], HostnameProcessor::class => [] ], //global handlers 'handlers' => [ Monolog\Handler\StreamHandler::class => [ 'stream' => '/var/log/global.log', 'fingersCrossed' => Logger::DEBUG, 'whatFailure' => true ], ], //logger services Monolog\Logger::class => [ 'channel_name' => 'php', //logger specific processors 'processors' => [ ProcessIdProcessor::class => [] ], //logger specific handlers 'handlers' => [ Monolog\Handler\StreamHandler::class => [ 'stream' => '/var/log/php.log' ], ] ], 'ApplicationLogger' => [ 'channel_name' => 'application', 'handlers' => [ Monolog\Handler\StreamHandler::class => [ 'stream' => '/var/log/application.log' ], ] ], 'RequestLogger' => [ 'channel_name' => 'requests' ], 'ErrorLogger' => [ 'channel_name' => 'errors', 'processors' => [], 'handlers' => [ Monolog\Handler\ErrorLogHandler::class => [] ] ], 'ConsoleLogger' => [ 'channel_name' => 'console' ], 'SecurityLogger' => [ 'channel_name' => 'security' ] ], ];
License
Copyright 2020 SmartFrame Technologies
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.