承接 yoeriboven/laravel-log-db 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yoeriboven/laravel-log-db

最新稳定版本:2.1

Composer 安装命令:

composer require yoeriboven/laravel-log-db

包简介

A database driver for logging with Laravel

README 文档

README

Laravel Database Logger

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a custom log driver for storing Laravel log messages in the database.

Compatible with Laravel 9, 10, 11 and 12.

use Illuminate\Support\Facades\Log;

Log::channel('db')->info('Your message');

Installation

Install the package via Composer:

composer require yoeriboven/laravel-log-db

Publish and run the migrations:

php artisan vendor:publish --tag="log-db-migrations"
php artisan migrate

Next, configure the database channel in config/logging.php:

use Yoeriboven\LaravelLogDb\DatabaseLogger;

return [
    'channels' => [
        'db' => [
            'driver'     => 'custom',
            'via'        => DatabaseLogger::class,
            'connection' => env('LOG_DB_CONNECTION'), // Optional, defaults to app's DB connection
            'days'       => 7, // Optional, retention period in days
            'level'      => env('LOG_LEVEL', 'debug'), // Optional
        ],
    ]   
]

Usage

To use the database channel, either:

  • Add it to the stack channel for combined logging:
// config/logging.php
return [
    'channels' => [
        'stack' => [
            'channels' => ['single', 'db'],
        ],
        // other channels
    ]
]
  • Log directly to the database:
use Illuminate\Support\Facades\Log;

Log::channel('db')->info('Your log message');

Fallback channel

If the database is unavailable, you can define a fallback channel to handle logs:

// config/logging.php

return [
    'channels' => [
        'fallback' => [
            'channels' => ['single'],
        ],
    ]   
]

If no fallback channel is defined it will default to the single channel.

Pruning the logs

To automatically delete logs older than a specified number of days, set the days key in the configuration and schedule log pruning:

$schedule->command('model:prune', [
    '--model' => [
        \Yoeriboven\LaravelLogDb\Models\LogMessage::class,
    ],
])->daily();

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

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

GitHub 信息

  • Stars: 55
  • Watchers: 4
  • Forks: 14
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固