大学 / 日志包
Symfony应用程序中的扩展日志选项
9.0.0
2022-07-18 19:00 UTC
Requires
- php: ^8.1
- ext-mbstring: *
- ext-sockets: *
- graylog2/gelf-php: ^1.7
- monolog/monolog: ^3.1
- symfony/console: ^5.3 || ^6.0
- symfony/dependency-injection: ^5.3 || ^6.0
- symfony/doctrine-bridge: ^5.3 || ^6.0
- symfony/framework-bundle: ^5.3 || ^6.0
- symfony/monolog-bundle: ^3.0
- symfony/security-core: ^5.3 || ^6.0
- symfony/stopwatch: ^5.3 || ^6.0
- symfony/var-dumper: ^5.3 || ^6.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.28
- php-mock/php-mock-phpunit: ^2.2
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.8
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^9.5.20
- symfony/yaml: ^5.3 || ^6.0
README
变更日志
查看CHANGELOG.md
安装
步骤 1
使用composer进行安装
"require": { "vysokeskoly/logging-bundle" : "^9.0" },
步骤 2
将VysokeSkolyLoggingBundle添加到AppKernel的加载包列表中。配置包所需参数。
config.yml
# bundle configuration vysoke_skoly_logging: app_id: appcz #should not contain dot (.) graylog: hostname: log01 facility: app.cz doctrine_execute_time_threshold: 0 # optional, in ms, null will disable this feature # add channel monolog.logger.perflog and optionally also businesslog channel monolog: channels: ["perflog", "businesslog"]
步骤 3
配置monolog日志选项。
config_prod.yml
monolog: handlers: main: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: notice formatter: vysokeskoly.monolog.formatter.extended channels: ["!perflog", "!businesslog"] console: type: console gelf: type: gelf level: notice publisher: vysokeskoly.monolog.handler.gelf formatter: vysokeskoly.monolog.formatter.gelf.message channels: ["!businesslog"]
命令性能日志
HTTP请求的性能日志默认启用,但您也可以启用CLI命令的性能日志。
您只需将您想要进行性能日志记录的命令实现为PerfloggableCommandInterface
即可,如下所示
class MyGreatCommand extends Command implements PerfloggableCommandInterface { ... }
此命令的执行时间将被测量并发送到名为perflog
的通道,度量名称根据命令名称命名。