大学/日志包

Symfony应用程序中的扩展日志选项

安装数量: 8,655

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

公开问题: 0

类型:symfony-bundle

9.0.0 2022-07-18 19:00 UTC

This package is auto-updated.

Last update: 2024-09-18 23:39:46 UTC


README

Latest Stable Version License Checks Build Coverage Status

变更日志

查看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的通道,度量名称根据命令名称命名。