Log function--yii::trace () and Yii::log ()

Source: Internet
Author: User

Yii provides a flexible and extensible logging capability. Message records can be categorized according to the log level and the category of the message. Using the level and category filters, the selected messages can be further logged to different destinations, such as files, e-mail, browser windows, and so on.


1. Turn on trace () and log ()

Log Route class:
Cdblogroute: Saves the information to a table in the database.
Cemaillogroute: Send the message to the specified email address.
Cfilelogroute: Saves the information to a file in the Application Runtime directory.
Cweblogroute: Displays information at the bottom of the current page.
Cprofilelogroute: Displays overview (profiling) information at the bottom of the page.

Information level levels:
Trace: This is the level used in Yii::trace. It is used to track the execution process of a program in development.
Info: This is used to record common information.
Profile: This is a performance overview (profile).
Warning: This is used for warning (warning) information.
Error: This is used for fatal errors (fatal error) information.


File config/main.php:
' DB ' =>array (...            /             * * Below is the debug information that shows the database operation performed             */            ' enableprofiling ' =>yii_debug,            ' enableparamlogging ' =>yii_debug,        ),        ... ...        ' Log ' =>array ' (            ' class ' = ' Clogrouter ',            ' routes ' =>array ('                    class ' = ') ' Cfilelogroute ',                    ' levels ' = ' Trace, info ',                    ' categories ' = ' system.* ', ', ', '                array (                    ' Class ' = ' Cemaillogroute ',                    ' levels ' = ' Error, warning ',                    ' emails ' = ' [email protected] ',            ),        ),



2. The difference between trace () and log ():
Trace () will only take effect in debug mode, that is, when Debug is turned on;
Trace () has no level, but log () can set the levels parameter.


File index.php:
<?php//remove the following lines when in production modedefined (' Yii_debug ') or define (' Yii_debug ', true);//Specify H OW many levels of call stack should is shown in each log messagedefined (' Yii_trace_level ') or define (' Yii_trace_level ', 9); 3



3. How to use:



Log function--yii::trace () and Yii::log ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.