MonologBundle配置信息("monolog"根键)

3.4 版本
维护中的版本

对于handler类型的完整清单及其相关配置选项,参考Monolog Configuration

完整的默认配置 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
monolog:
    handlers:

        # Examples / 样例 :
        syslog:
            type:                stream
            path:                /var/log/symfony.log
            level:               ERROR
            bubble:              false
            formatter:           my_formatter
        main:
            type:                fingers_crossed
            action_level:        WARNING
            # By default, buffer_size is unlimited (0), which could
            # generate huge logs.
            # 默认时,buffer_size是无限的(0),可生成巨大(容量的)日志。
            buffer_size:         0
            handler:             custom
        console:
            type:                console
            verbosity_levels:
                VERBOSITY_NORMAL:       WARNING
                VERBOSITY_VERBOSE:      NOTICE
                VERBOSITY_VERY_VERBOSE: INFO
                VERBOSITY_DEBUG:        DEBUG
        custom:
            type:                service
            id:                  my_handler
 
        # Default options and values for some "my_custom_handler"
        # Note: many of these options are specific to the "type".
        # For example, the 'service' type doesn't use any options
        # except id and channels
        # 一些“自定义handler”所需之选项和选项值
        # 注意:其中的很多选项是因“type”而异的。
        # 比如,“service” type就不使用id和channel以外的任何选项
        my_custom_handler:
            type:                 ~ # Required
            id:                   ~
            priority:             0
            level:                DEBUG
            bubble:               true
            path:                 "%kernel.logs_dir%/%kernel.environment%.log"
            ident:                false
            facility:             user
            max_files:            0
            action_level:         WARNING
            activation_strategy:  ~
            stop_buffering:       true
            buffer_size:          0
            handler:              ~
            members:              []
            channels:
                type:     ~
                elements: ~
            from_email:           ~
            to_email:             ~
            subject:              ~
            mailer:               ~
            email_prototype:
                id:                   ~ # Required (when the email_prototype is used)
                                        # 必填项(当使用email_prototype时) 
                method:               ~
            formatter:            ~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:monolog="http://symfony.com/schema/dic/monolog"
    xsi:schemaLocation="http://symfony.com/schema/dic/services
        http://symfony.com/schema/dic/services/services-1.0.xsd
        http://symfony.com/schema/dic/monolog
        http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"
>
 
    <monolog:config>
        <monolog:handler
            name="syslog"
            type="stream"
            path="/var/log/symfony.log"
            level="error"
            bubble="false"
            formatter="my_formatter"
        />
 
        <!-- By default, buffer-size is unlimited (0), which could
             generate huge logs. -->
        <monolog:handler
            name="main"
            type="fingers_crossed"
            action-level="warning"
            handler="custom"
            buffer-size="0"
        />
 
        <monolog:handler
            name="console"
            type="console"
        />
 
        <monolog:handler
            name="custom"
            type="service"
            id="my_handler"
        />
    </monolog:config>
</container>

当profiler(sf除错工具条中的profiler,即页面分析器)开启时,将会添加一个用于存储profiler中的日志信息的handler。分析器对其使用的名字是“debug”,因此这个名字被保留了而不能用在配置信息中。

本文,包括例程代码在内,采用的是 Creative Commons BY-SA 3.0 创作共用授权。

登录symfonychina 发表评论或留下问题(我们会尽量回复)