flowpack/monolog

此包的最新版本(2.1.0)没有可用的许可信息。

Flow 的 Monolog 集成

安装次数: 18,808

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:neos-package

2.1.0 2024-01-17 09:49 UTC

This package is auto-updated.

Last update: 2024-09-05 13:55:55 UTC


README

为 Flow 提供 monolog 工厂。

此包默认将所有 Neos Flow 日志(安全、系统、查询、国际化)替换为 Monolog。要更改此设置和处理程序,请检查 Settings.yaml。有关配置说明,请参阅下面的说明。

👻

Monolog 的格式与默认 Flow 日志文件格式略有不同。此外,配置的 Monolog 处理程序不会像 Flow 日志那样进行日志轮转,因此您需要注意这一点。

安装

使用 composer 安装此包

composer require flowpack/monolog

所有框架日志现在应使用 monolog 格式,并且您需要添加配置以处理其他可能需要的日志。

配置

您可以通过多种方式使用此包配置 monolog,最简单的方法是查看此包中 Neos Flow 日志的配置。

Neos:
  Flow:
    log:
      psr3:
        'Flowpack\Monolog\LoggerFactory':
          # name of the logger as Flow addresses it, eg. "systemLogger"
          '<name of the logger>':
            handler:
              # unique name for this handler in this log, for extending the configuration
              '<identifier for this handler>':
                className: '<monolog compatible handler class name fully qualified>'
                # sorting for this handler if you want it deterministic with overwrites
                position: 100
                # arguments given to the handler, zero index based, as the handler constructor expects them
                arguments:
                  0: '<the first argument given to the constructor of the handler>'
              # another handler could follow here

另一种选择是创建预设处理程序,例如,如果您需要在多个位置使用具有相同配置的相同处理程序,则目前无法覆盖此默认配置。

Flowpack:
  Monolog:
    handler:
      # unique identifier of this handler (preset)
      '<presetName>':
        className: '<monolog compatible handler class name fully qualified>'
        # note that preset handlers currently cannot have a position, they are sorted as configured
        # arguments given to the handler, zero index based, as the handler constructor expects them
        arguments:
            0: '<the first argument given to the constructor of the handler>'

Neos:
  Flow:
    log:
      psr3:
        'Flowpack\Monolog\LoggerFactory':
          # name of the logger as Flow addresses it
          '<name of the logger>':
            handler:
              # the presetName should be the same as in above preset configuration
              '<identifier for this handler>': '<presetName>'

⚠️ 注意,由于 Flowpack.Monolog 包的设置注入较晚,因此预设在此时的启动过程中不起作用。

处理程序

有关处理程序及其配置的更多信息,请参阅 monolog 的 处理程序、格式化程序和处理器文档

格式化程序

要将格式化程序添加到处理程序,请按以下方式配置它

Neos:
  Flow:
    log:
      psr3:
        'Flowpack\Monolog\LoggerFactory':
          '<name of the logger>':
            handler:
              '<identifier for this handler>':
                className: '<monolog compatible handler class name fully qualified>'
                arguments:
                  0: '<the first argument given to the constructor of the handler>'
                # any formatter compatible with monolog
                formatterClassName: '<monolog compatible formatter class name fully qualified>'
                # optional arguments for the formatter
                formatterArguments:
                  0: '<the first argument given to the constructor of the formatter>'

为此要工作,使用的处理程序必须实现 monolog 的 FormattableHandlerInterface

有关格式化程序及其配置的更多信息,请参阅 monolog 的 处理程序、格式化程序和处理器文档