ubatgroup/graylog 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ubatgroup/graylog

Composer 安装命令:

composer require ubatgroup/graylog

包简介

A package to send logs to graylog

README 文档

README

It is a laravel wrapper for bzikarsky/gelf-php package.

This package was developed for an internal need. No maintenance's planned.

Installation

Install via composer

composer require ubatgroup/graylog

Only for Laravel 5 to 5.3

Add it to your providers array in config/app.php:

Ubatgroup\Graylog\GraylogServiceProvider::class

To use the facade, add it to your aliases array in config/app.php:

'Graylog' => Ubatgroup\Graylog\Facades\Graylog::class

For Laravel 5.4 and more

Laravel auto discover new packages

composer dump-autoload

Configuration

Set the graylog configuration into the .env file :

  • GRAYLOG_SERVER : server graylog ip (if this key is not set, it uses 127.0.0.1)
  • GRAYLOG_PORT : server graylog port (if this key is not set, it uses 12201)
  • GRAYLOG_FACILITY : graylog facility filter (if this key is not set, it uses APP_URL key)
  • GRAYLOG_APPNAME : graylog source filter (if this key is not set, it uses APP_NAME key)
To override the configuration file :

First, publish the configuration file:

php artisan vendor:publish --provider="Ubatgroup\Graylog\GraylogServiceProvider"

See the content of the published configuration file in config/graylog.php.

// Address serveur host
'server'   => env( 'GRAYLOG_SERVER', '127.0.0.1' ),
 
// Port server host
'port'     => env( 'GRAYLOG_PORT', 12201 ),
 
// facility to filter logs (common use application URL)
'facility' => env( 'GRAYLOG_FACILITY', env( 'APP_URL', null ) ),
 
// host to filter logs (common use application name)
'host'     => env( 'GRAYLOG_HOST', env( 'APP_NAME', null ) ),
 
// Add Auth::user data automatically as AdditionaData in every exception handle by the connected user
'auto_log_auth_user' => true,

Usage

 Graylog::emergency( $message, array $context = array() );
 Graylog::alert( $message, array $context = array() );
 Graylog::critical( $message, array $context = array() );
 Graylog::error( $message, array $context = array() );
 Graylog::warning( $message, array $context = array() );
 Graylog::notice( $message, array $context = array() );
 Graylog::info( $message, array $context = array() );
 Graylog::debug( $message, array $context = array() );

See the bzikarsky/gelf-php examples in his repo to find the available methods for the Graylog facade.

Example

Graylog::alert('There was a foo in bar', [
    'foo' => 'bar',
    'other_context_key' => 'other_context_value',
]);
try {
    throw new \Exception('Nice exception !');
} catch (\Exception $e) {
    Graylog::emergency('Exception handled !', [
        'exception' => $e,
        'additionnal_data' => 'Hello world!
    ]);
}

Note

  • If auto_log_auth_user config key and Auth::check() are true, Auth::user() data are auto added to the context array (auth_user key)
  • If you need to use $guard to get the authenticated user, turn false the auto_log_auth_user config key and add it manually in additionnal data array
  • Don't use special/accentuated chars in context key for additionals data

License

This package is released under the MIT Licence.

ubatgroup/graylog 适用场景与选型建议

ubatgroup/graylog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ubatgroup/graylog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ubatgroup/graylog 我们能提供哪些服务?
定制开发 / 二次开发

基于 ubatgroup/graylog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-16