Home  >  Article  >  PHP Framework  >  Where is the yii log file?

Where is the yii log file?

(*-*)浩
(*-*)浩Original
2019-12-14 11:08:014201browse


Where is the yii log file?

##Yii provides a flexible and scalable logging function. Recorded logs can be classified by log level and information classification. (Recommended learning: yii framework)

By using level and classification filters, the selected information can also be further routed to different destinations, such as a file, Email, Browser window etc.

Information can be recorded through Yii::log or Yii::trace. The difference is that the latter only logs information when the application is running in debug mode.

Yii::log($message, $level, $category);
Yii::trace($message, $category);

When recording information, we need to specify its category and level. The category is a string in a format similar to a path alias. For example, if a message is recorded in CController, we can use system.web.CController as the classification. The information level should be one of the following values:

trace: This is the level used in Yii::trace. It is used to track the execution flow of a program during development.

info: This is used to record ordinary information.

profile: This is the performance overview (profile). More detailed instructions will follow shortly.

warning: This is used for warning information.

error: This is used for fatal error messages.

Although turning on log affects efficiency (reading and writing files), so log is usually disabled in production environments. However, we often need to record some necessary information, such as payment logs, so this creates new requirements: different information Log to different log files.

//在需要记录日志的地方先赋值log文件地址:
Yii::$app->log->targets[0]->logFile = Yii::getAlias('@runtime').DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR.'app2.log';
Yii::warning($message);

The above is the detailed content of Where is the yii log file?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Can yii2 connect to db2?Next article:Can yii2 connect to db2?