定制 markhilton/monolog-mysql 二次开发

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

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

markhilton/monolog-mysql

最新稳定版本:0.1.6

Composer 安装命令:

composer require markhilton/monolog-mysql

包简介

Laravel 8 MySQL driver for Monolog

README 文档

README

This package will log errors into MySQL database instead storage/log/laravel.log file.

Installation

composer require markhilton/monolog-mysql

Open up config/app.php and find the providers key.

'providers' => array( // ... Logger\Laravel\Provider\MonologMysqlHandlerServiceProvider::class, );

Publish config using Laravel Artisan CLI.

php artisan vendor:publish

Migrate tables - you may want to configure enviornment beforehand.

php artisan migrate

Application Integration

In your application config/logging.php add:

use Logger\Monolog\Handler\MysqlHandler; // ... 'channels' => [ // ... 'mysql' => [ 'driver' => 'monolog', 'handler' => MysqlHandler::class, 'level' => 'debug', ], ];

Application Integration (Laravel >= 5.6)

In your application config/logging.php add:

<?php // [...] 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['mysql'], ], // [...] 'mysql' => [ 'driver' => 'custom', 'via' => App\Logging\CreateMySQLLogger::class, ], ],

In your application app/Logging/CreateMySQLLogger.php add:

<?php namespace App\Logging; use Exception; use Monolog\Logger; use Logger\Monolog\Handler\MysqlHandler; class CreateMySQLLogger { /**  * Create a custom Monolog instance.  *  * @param array $config  * @return Logger  * @throws Exception  */ public function __invoke(array $config) { $channel = $config['name'] ?? env('APP_ENV'); $monolog = new Logger($channel); $monolog->pushHandler(new MysqlHandler()); return $monolog; } }

Environment configuration

If you wish to change default table name to write the log into or database connection use following definitions in your .env file

DB_LOG_TABLE=logs DB_LOG_CONNECTION=mysql

Credits

Based on:

统计信息

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

GitHub 信息

  • Stars: 40
  • Watchers: 2
  • Forks: 19
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固