yeebase/graylog
Composer 安装命令:
composer require yeebase/graylog
包简介
Graylog exception handler for Neos Flow
README 文档
README
The Yeebase.Graylog Flow package logs your exceptions as well as single messages to a central Graylog server. This package also provides a simple backend to log message of Flows Logger classes to a Graylog server.
It depends on the official GELF php package https://github.com/bzikarsky/gelf-php
Installation & configuration
Just add "yeebase/graylog" as dependency to your composer.json and run a "composer update" in your project's root folder or simply execute:
composer require yeebase/graylog
from your project's root.
Configure your Graylog Server:
Yeebase: Graylog: host: '127.0.0.1' port: 12201 chunksize: 'wan'
Logging backend
To configure GraylogBackend as the default logging backend, put this in your Settings.yaml:
Neos:
Flow:
log:
systemLogger:
backend: Yeebase\Graylog\Log\Backend\GraylogBackend
securityLogger:
backend: Yeebase\Graylog\Log\Backend\GraylogBackend
sqlLogger:
backend: Yeebase\Graylog\Log\Backend\GraylogBackend
i18nLogger:
backend: Yeebase\Graylog\Log\Backend\GraylogBackend
Log exceptions
Activate the exception handler and configure the connection to your graylog server in your Settings.yaml:
Neos: Flow: error: exceptionHandler: className: 'Yeebase\Graylog\Error\GraylogExceptionHandler'
Now all Exceptions that are shown to the Web or CLI are logged to graylog.
Note: For Development context, the Neos.Flow package overrides this setting. Make sure to add this configuration
in the right context Settings.yaml.
If you want to log additionally all Exceptions to graylog you should replace the systemLogger as well. This will log all errors that are logged with the SystemLogger to Graylog as well to the disk. By default Flow will only log a single line to the system log aka "See also ... .txt". The GraylogLogger will also log the full Exception.
Neos: Flow: log: systemLogger: logger: Yeebase\Graylog\Log\GraylogLogger
Filter exceptions
To skip certain exceptions from being logged you can either use the skipStatusCodes setting:
Yeebase: Graylog: # don't log any exceptions that would result in a HTTP status 403 (access denied) / 404 (not found) skipStatusCodes: [403, 404]
Since version 2.1 you can alternatively use the renderingGroups Flow setting, i.e. to exclude certain Exception
classes from being logged:
Neos: Flow: error: exceptionHandler: className: 'Yeebase\Graylog\Error\GraylogExceptionHandler' renderingGroups: 'accessDeniedExceptions': matchingExceptionClassNames: ['Neos\Flow\Security\Exception\AccessDeniedException'] options: logException: false
Manual logging
If you wish to log normal log messages to your Graylog server just use the provided GraylogLoggerInterface:
use Neos\Flow\Annotations as Flow; use Yeebase\Graylog\Log\GraylogLoggerInterface; class SomeClass { /** * @Flow\Inject * @var GraylogLoggerInterface */ protected $graylogLogger; public function yourMethod() { $this->graylogLogger->log('Your Message') } }
By default messages will also be logged to the SystemLoggerInterface when Flow runs in Development context. You
can enable or disable this function with a setting:
Yeebase: Graylog: Logger: backendOptions: alsoLogWithSystemLogger: true
Extend the message context
By default this package will send a bunch of values to graylog you can use to filter on. A Exception for instance has
some fields like reference_code, response_status_code and so on.
You can extend those values via Settings.yaml. Just pass an array of values to Yeebase.Graylog.messageContext.
This is useful to pass some static values to your logs to filter on in Graylog.
Yeebase: Graylog: messageContext: app_context: 'stage'
yeebase/graylog 适用场景与选型建议
yeebase/graylog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.94k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2015 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 yeebase/graylog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yeebase/graylog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-24