thedomeffm/monolog-dbal-handler-bundle

DBAl (doctrine) 处理器,用于将日志推送到数据库

v0.0.1 2023-12-14 13:23 UTC

This package is not auto-updated.

Last update: 2024-09-20 15:11:29 UTC


README

为monolog添加一个处理器,可以将您的日志持久化到数据库中。默认表名为monolog_log,并使用monolog json格式化器来格式化日志。

安装

composer require thedomeffm/monolog-dbal-handler-bundle

配置

您可以选择覆盖表名。由于我还没有添加配方(或我需要创建的东西 🤷),因此您需要自己创建配置。

# thedomeffm_monolog_dbal_handler.yaml

thedomeffm_monolog_dbal_handler:
    dbal:
        log_table_name: "the_table_name_you_prefer"

编辑您的monolog配置

# monolog.yaml

monolog:
    handlers:
        # your other handler...
        dbal:
            type: service
            id: thedomeffm_monolog_dbal_handler

以下是一个生产配置示例

# monolog.yaml

when@prod:
    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: main_group
                excluded_http_codes: [404, 405]
                buffer_size: 50

            main_group:
                type: group
                members: ['error_stream', 'dbal']

            error_stream:
                type: stream
                path: php://stderr
                level: debug
                formatter: monolog.formatter.json

            dbal:
                type: service
                id: thedomeffm_monolog_dbal_handler

            # your other handler...