anthonyedmonds/laravel-database-log
最新稳定版本:2.1.1
Composer 安装命令:
composer require anthonyedmonds/laravel-database-log
包简介
Store your Laravel logs in the database
README 文档
README
Store your Laravel logs in the database!
Installation
- Add the library using Composer:
composer require anthonyedmonds/laravel-database-log - The service provider will be automatically registered.
If required, you can manually register the service provider by adding it to your
bootstrap/providers.php:return [ ... AnthonyEdmonds\LaravelDatabaseLog\DatabaseLogServiceProvider::class, ... ]; - Publish the database migration and config files using Artisan:
php artisan vendor:publish --provider="AnthonyEdmonds\LaravelDatabaseLog\DatabaseLogServiceProvider" - Add a log channel to 'config/logging.php' based on the following:
'channels' => [ ... 'database' => [ 'driver' => 'monolog', 'handler' => AnthonyEdmonds\LaravelDatabaseLog\Handler::class, 'with' => [ 'fallback' => 'daily', ], 'level' => env('LOG_LEVEL', 'debug'), ], ... ],- The
fallbackparameter is optional, and can point to a log to use in case the database cannot be reached. - The
levelparameter can be excluded if desired.
- The
Configuration
The configuration found at config/database-log.php allows you to customise the following:
| Field | Default | Purpose |
|---|---|---|
| model | AnthonyEdmonds\LaravelDatabaseLog\Log | The class name of the model to use for storing logs in the database |
| table | logs | The name of the table used to store database logs |
Cleaning up old logs
Job
A Laravel Job is provided to cleanup old logs.
Add the job to your schedule, providing the number of days after which logs should be deleted.
$schedule ->job(new CleanupLogsJob()) ->daily();
Command
The database-log:cleanup command is also provided to remove old logs from the database as required.
You can provide the number of days after which logs should be deleted as part of the command.
php artisan database-log:cleanup 14
You can also schedule the command to run automatically by adding it to your scheduler:
$schedule
->command('database-log:cleanup 90')
->daily();
Usage
Whenever Laravel creates a log, whether manually or when exceptions are thrown, a new Log will be created in the database.
You are free to use those Logs in whatever fashion you see fit; no UI or other restrictions are provided by this library.
Issues and feedback
You are welcome to raise issues on Github to provide bug reports, issues, and feedback.
统计信息
- 总下载量: 3.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-04