Also available in these languages:
English日本語polskiРусский简体中文

Logging Errors

A production Web application often needs sophisticated logging for various events. In our blog application, we would like to log the errors occurring when it is being used. Such errors could be programming mistakes or users' misuse of the system. Logging these errors will help us to improve the blog application.

We enable the error logging by modifying the application configuration as follows,

return array(
    'preload'=>array('log'),
 
    ......
 
    'components'=>array(
        'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error, warning',
                ),
            ),
        ),
        ......
    ),
);

With the above configuration, if an error or warning occurs, detailed information will be logged and saved in a file located under the directory /wwwroot/blog/protected/runtime.

The log component offers more advanced features, such as sending log messages to a list of email addresses, displaying log messages in JavaScript console window, etc. For more details, please refer to the Guide.

$Id: final.logging.txt 878 2009-03-23 15:31:21Z qiang.xue $
If you found any typos or errors in the tutorial, please create a Yii ticket to report it. If it is a translation error, please create a Yiidoc ticket, instead. Thank you.

Your Comment:

You may enter comment using Markdown syntax.

Please login with your forum account.
Note: you must have at least ONE forum post with your account.