jeff/lara-logger
最新稳定版本:v0.0.2
Composer 安装命令:
composer require jeff/lara-logger
包简介
Add logs in your laravel project in database
README 文档
README
LaraLogger is a Laravel package that provides a custom logging solution to store log entries directly in a database. This package includes a ready-to-use DatabaseLogger channel and provides necessary migrations to set up a logs table.
Features
- Custom Log Channel: Store logs in the database using a dedicated channel.
- Database Migration: Automatic setup for a
logstable. - Configurable: Easily integrate into your existing Laravel logging configuration.
Installation
- Install the package using Composer:
composer require jeff/lara-logger
- Add
Jeff\LaraLogger\Providers\LoggingServiceProvider::classto providers list (/bootstrap/providers.php):
<?php return [ ..., Jeff\LaraLogger\Providers\LoggingServiceProvider::class, ];
- Run the Publish command (optional):
php artisan vendor:publish --provider="Jeff\LaraLogger\Providers\LoggingServiceProvider"
- Run the migrations to create the logs table:
php artisan migrate
- Add the following logging-related environment variables to your .env file if needed:
LOG_CHANNEL=database LOG_STACK=custom
Usage
- Add Logs:
\Illuminate\Support\Facades\Log::info('test ok'); \Illuminate\Support\Facades\Log::info('test ok', [ ... , 'test' => 'tests' ]); \Illuminate\Support\Facades\Log::error('test ok'); \Illuminate\Support\Facades\Log::warning('test ok'); \Illuminate\Support\Facades\Log::channel('database')->info('test ok');
- List Logs, (ex: in a route function):
return \Jeff\LaraLogger\App\Models\LogModel::all(['*']);
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-01