nagi/laravel-newrelic-log-api
Composer 安装命令:
composer require nagi/laravel-newrelic-log-api
包简介
This is my package laravel-newrelic-log-api
README 文档
README
Integrate New Relic Log API with Laravel your laravel application. It mainly utilizing queues behind the scene to send the logs to New Relic API. so make sure you have queue worker running.
Supports Laravel 11, 12, and 13 on PHP 8.3+.
// in loggin.php 'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'newrelic-log-api'], 'ignore_exceptions' => false, ], //... 'newrelic-log-api' => [ 'driver' => 'monolog', 'handler' => \Nagi\LaravelNewrelicLogApi\LaravelNewrelicLogApi::logHandler(), 'level' => 'debug', ],
logger('newrelic-log-api')->info('Hey Mom!'); // or if you are using stack logger()->info('Hey Mom!');
Support Me
Does your business depend on my contributions? Reach out and support me on PayPal. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
Installation
You can install the package via composer:
composer require nagi/laravel-newrelic-log-api
For local package development, Laravel Boost is available as a dev dependency.
You can publish the config file with:
php artisan vendor:publish --tag="laravel-newrelic-log-api-config"
This is the contents of the published config file:
return [ 'enabled' => env('NEWRELIC_ENABLED', false), /** * New Relic API key or License key * * @see https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#setup */ 'api_key' => env('NEWRELIC_API_KEY'), /** * The base URL for the new relic log API * * @see https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#endpoint */ 'base_url' => env('NEWRELIC_BASE_URL', 'https://log-api.eu.newrelic.com'), /** * The minimum logging level at which this handler will be triggered */ 'level' => env('NEWRELIC_LEVEL', 'debug'), /** * Retry sending the log to New Relic API */ 'retry' => env('NEWRELIC_RETRY', 3), /** * Delay between retries in milliseconds */ 'retry_delay' => env('NEWRELIC_RETRY_DELAY', 1000), /** * Queue name to use for sending logs to New Relic API */ 'queue' => env('NEWRELIC_QUEUE', 'default'), /** * Log handler to use for sending logs to New Relic API */ 'log_handler' => \Nagi\LaravelNewrelicLogApi\NewrelicLogHandler::class, ];
🚨 Make sure that you have queue worker configured.
Usage
Get your newrelic License/API
https://one.newrelic.com/api-keys
Add env values in your .env
NEWRELIC_ENABLED=true
NEWRELIC_API_KEY=<your_key>
# if your account is not EU change the baseurl
# https://log-api.newrelic.com/log/v1
NEWRELIC_BASE_URL=https://log-api.eu.newrelic.com
Add new relic channel to your config
In your logging.php add new-relic-log-api channel
'newrelic-log-api' => [ 'driver' => 'monolog', 'handler' => \Nagi\LaravelNewrelicLogApi\LaravelNewrelicLogApi::logHandler(), 'level' => env('NEWRELIC_LEVEL', 'debug') ],
Add it to your logging stack
in logging.php
'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'newrelic-log-api'], 'ignore_exceptions' => false, ],
Listen to the event
If you are intrested in geting the response from the New Relic API you can listen to the event NewrelicLogApiResponseEvent It will have the status and the response from the API.
protected $listen = [ NewrelicLogApiResponseEvent::class => [ NewrelicLogApiResponseListener::class, ], ];
Note on context log (attributes)
When sending one of the following attributes in the context it will be prefixed with attr_ to avoid overriding the whole message.
See: New Relic Log API
Extending
All of the classes in this package are loaded via Laravel's service container meaning you can easily replace them with your own implementation. On Your Own Risk.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
nagi/laravel-newrelic-log-api 适用场景与选型建议
nagi/laravel-newrelic-log-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 556 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Ahmed Nagi」 「laravel-newrelic-log-api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nagi/laravel-newrelic-log-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nagi/laravel-newrelic-log-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nagi/laravel-newrelic-log-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Wopi implementation in php Laravel
A wrapper package over spatie query builder package to simplify filters creation for Laravel Apps
Alfabank REST API integration
Sentiment analyzer Package for Laravel Framework
Deploy your project to server using bitbucket
Extend your date fields to reveal the date in other time zones on hover as well as relative time.
统计信息
- 总下载量: 556
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-09