deamon / logger-extra-bundle
此组件旨在为您的日志添加一些额外的上下文信息。
v6.1.0
2022-08-03 14:18 UTC
Requires
- php: >=8.0.2
- monolog/monolog: ^3.0
- symfony/config: ^6.0
- symfony/dependency-injection: ^6.0
- symfony/http-foundation: ^6.0
- symfony/http-kernel: ^6.0
- symfony/monolog-bridge: ^6.0
- symfony/security-core: ^6.0
Requires (Dev)
- symfony/phpunit-bridge: ^6.0
Suggests
- graylog2/gelf-php: For the possibility to send monolog messages to a graylog server such as ELK
This package is auto-updated.
Last update: 2024-09-03 17:49:10 UTC
README
本项目用于在日志中添加额外的上下文信息。
如果您需要与先前版本的Symfony兼容,请查看之前的版本。
要求
php >=8.0.2
symfony/security-core symfony/dependency-injection symfony/monolog-bridge symfony/http-kernel symfony/http-foundation symfony/config
从6.0版本开始兼容Symfony。
标签遵循Symfony版本。
安装
您需要将包添加到您的依赖列表中
// composer.json
"deamon/logger-extra-bundle": "^6.0"
然后启用内核中的组件
// config/bundles.php
return [
// ...
App\Acme\TestBundle\AcmeTestBundle::class => ['all' => true],
];
最后,您需要配置该组件。
配置示例
给定此项目配置示例
// config/packages/monolog.yml
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
使用此Monolog配置示例,您可以配置此组件仅在main
处理器上添加额外信息。
// config/packages/deamon_logger_extra.yml
deamon_logger_extra:
application:
name: "loc-deamonfront"
version: "v0.1"
handlers: [main]
配置参考
// config/packages/deamon_logger_extra.yaml
deamon_logger_extra:
application:
name: "loc-deamonfront" # default to null
locale: "fr" # default to null
version: "v0.1" # default to null
handlers: [main] # the only required field
config:
channel_prefix: "v0.1" # default to null
user_class: "\\Symfony\\\Component\\Security\\Core\\User\\UserInterface" # default to null
user_methods:
user_name: getUsername # default value
display:
env: false # default to true
locale: false # default to true
application_name: false # default to true
url: false # default to true
route: false # default to true
user_agent: false # default to true
accept_encoding: false # default to true
client_ip: false # default to true
user: false # default to true
global_channel: false # default to true
最小配置
// config/packages/deamon_logger_extra.yaml
deamon_logger_extra:
application: null
handlers: ['main']
config: null