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 ()