aainc/newrelic-logger
Composer 安装命令:
composer require aainc/newrelic-logger
包简介
README 文档
README
Description
Laravel 上で Newrelic Logs を利用するとき、ログに出力される内容をコントロールするためのライブラリ。
message に送信された文字列や配列、例外をパースして Newrelic Logs へ送信する。
Requirements
- PHP 7.1 or higher
- Laravel 5.4 or higher
- Newrelic api key
Get Started
Installation
composer require aainc/newrelic-logger
Initialize
config/logging.php
'stack' => [ 'driver' => 'stack', 'channels' => ['single','newrelic'], 'ignore_exceptions' => false, ], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'newrelic' => [ 'driver' => 'monolog', 'handler'=> \NewRelic\Monolog\Enricher\Handler::class, 'tap' => [\Aainc\NewrelicLogger\NewRelicLogs::class], 'level' => env('LOG_LEVEL', 'debug'), 'formatter' => 'default', ],
config/aa-newrelic-logger.php
<?php return [ // Minimum log level describing additional information (default:DEBUG) 'log_level' => \Monolog\Logger::DEBUG, // This may be useful if the New Relic PHP agent is not installed, or if you wish to log to a different account or region. // (default:null) 'license_key' => null, // Can use this to log output with server environment variable information. 'extra_data' => [] ];
Example
<?php return [ 'log_level' => \Monolog\Logger::DEBUG, 'license_key' => getenv('NEWRELIC_LICENSE_KEY'), 'extra_data' => [ 'host_name' => getenv('HOST_NAME') ] ];
Send Logs
Send text message
Log::debug('Send text);
Send array message
Log::debug('array', [ 'hoge' => 'fuga', 'hogehoge' => 'fugafuga' ]);
Send Exception
Log::debug(new Exception('message');
统计信息
- 总下载量: 51
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-04