定制 neeckeloo/monolog-module 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

neeckeloo/monolog-module

最新稳定版本:v1.3.0

Composer 安装命令:

composer require neeckeloo/monolog-module

包简介

Monolog integration into Laminas

README 文档

README

Module to integrate Monolog with Laminas projects.

Build Status Latest Stable Version Total Downloads Coverage Status

Requirements

Installation

MonologModule must be installed through Composer. For Composer documentation, please refer to getcomposer.org.

You can install the module from command line:

$ composer require neeckeloo/monolog-module

Enable the module by adding MonologModule key in your application.config.php file.

Usage

Configuring a logger

This is the configuration of a logger that can be retrieved with key Log\App in the service manager. A channel name default is also defined to identify to which part of the application a record is related.

return [ 'monolog' => [ 'loggers' => [ 'Log\App' => [ 'name' => 'default', ], ], ], ];

Adding a handler

The logger itself does not know how to handle a record. It delegates it to some handlers. The code above registers two handlers in the stack to allow handling records in two different ways.

return [ 'monolog' => [ 'loggers' => [ 'Log\App' => [ 'name' => 'default', 'handlers' => [ 'stream' => [ 'name' => StreamHandler::class, 'options' => [ 'path' => 'data/log/application.log', 'level' => Logger::DEBUG, ], ], 'fire_php' => [ 'name' => FirePHPHandler::class, ], ], ], ], ], ];

Using processors

If you want to add extra information (tags, user IP, ...) to the records before they are handled, you should add some processors. The code above adds two processors that add an unique identifier and the current request URI, request method and client IP to a log record.

return [ 'monolog' => [ 'loggers' => [ 'Log\App' => [ 'name' => 'default', 'handlers' => [ 'default' => [ 'name' => StreamHandler::class, 'options' => [ 'path' => 'data/log/application.log', 'level' => Logger::DEBUG, ], ], ], 'processors' => [ UidProcessor::class, WebProcessor::class, ], ], ], ], ];

You can also add processors to a specific handler.

return [ 'monolog' => [ 'loggers' => [ 'Log\App' => [ 'name' => 'default', 'handlers' => [ 'default' => [ 'name' => StreamHandler::class, 'options' => [ 'path' => 'data/log/application.log', 'level' => Logger::DEBUG, ], 'processors' => [ UidProcessor::class, WebProcessor::class, ], ], ], ], ], ], ];

Retrieving a logger

Once the configuration is complete, you can retrieve an instance of the logger as below:

$logger = $serviceManager->get('Log\App'); $logger->debug('debug message');

Testing

$ vendor/bin/phpunit

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 185.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固