nix-logger / nix-logger-laravel
Nix Logger
v1.3
2024-03-27 08:20 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^9.0|^10.0
- illuminate/support: ^9.0|^10.0
- monolog/monolog: ^2 || ^3
- nix-logger/nix-logger: ^1.1
- psr/log: ^3.0
Requires (Dev)
- laravel/pint: ^1.13
README
安装
安装 nix-logger/nix-logger-laravel
包
composer require nix-logger/nix-logger-laravel
在 config/app.php
文件的 providers
数组中添加服务提供者,在 AppServiceProvider::class
之前
NixLogger\Laravel\NixLoggerServiceProvider::class,
在 config/app.php
文件的 aliases
数组中添加 Facade
'NixLogger' => NixLogger\Laravel\Facades\NixLogger::class,
配置
通过编辑 .env
文件来配置 Nix-Logger
# .env
NIX_LOGGER_API_KEY=
APP_ENV=
NIX_LOGGER_LEVEL=critical,error,warning
如果您想进一步配置 Nix-Logger,创建并编辑一个 config/nix-logger.php
文件
设置日志报告
在 config/logging.php
中,通过在 channels
键下添加以下内容来添加 nix-logger
日志通道
'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'nix-logger'], 'ignore_exceptions' => false, ], 'nix-logger' => [ 'driver' => 'custom', 'via' => \NixLogger\Laravel\Logger\NixLogger::class, ],
针对 stderr
'channels' => [ 'stderr' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => \NixLogger\Laravel\Handlers\NixLoggerStreamHandler::class, 'formatter' => env('LOG_STDERR_FORMATTER'), 'with' => [ 'stream' => 'php://stderr', ], 'processors' => [PsrLogMessageProcessor::class], ], ]
用法
\NixLogger::debug('Test');