码迷,mamicode.com
首页 > 其他好文 > 详细

Yii::log 正式环境不起作用

时间:2015-05-21 17:20:09      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

Message Routing 

Messages logged using Yii::log or Yii::trace are kept in memory. We usually need to display them in browser windows, or save them in some persistent storage such as files, emails. This is called message routing, i.e., sending messages to different destinations.

In Yii, message routing is managed by a CLogRouter application component. It manages a set of the so-calledlog routes. Each log route represents a single log destination. Messages sent along a log route can be filtered according to their levels and categories.

To use message routing, we need to install and preload a CLogRouter application component. We also need to configure its routes property with the log routes that we want. The following shows an example of the needed application configuration:

array(
    ......
    preload=>array(log),
    components=>array(
        ......
        log=>array(
            class=>CLogRouter,
            routes=>array(
                array(
                    class=>CFileLogRoute,
                    levels=>trace, info,
                    categories=>system.*,
                ),
                array(
                    class=>CEmailLogRoute,
                    levels=>error, warning,
                    emails=>admin@example.com,
                ),
            ),
        ),
    ),
)

In the above example, we have two log routes. The first route is CFileLogRoute which saves messages in a file under the application runtime directory. Only messages whose level is trace or info and whose category starts with system. are saved. The second route is CEmailLogRoute which sends messages to the specified email addresses. Only messages whose level is error or warning are sent.

Yii::log 正式环境不起作用

标签:

原文地址:http://www.cnblogs.com/51cas/p/4519931.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!