@@ -5,7 +5,7 @@ Yii provides a powerful logging framework that is highly customizable and extens
...
@@ -5,7 +5,7 @@ Yii provides a powerful logging framework that is highly customizable and extens
can easily log various types of messages, filter them, and gather them at different targets, such as files, databases,
can easily log various types of messages, filter them, and gather them at different targets, such as files, databases,
emails.
emails.
Using the Yii logging framework involves the following steps of work:
Using the Yii logging framework involves the following steps:
* Record [log messages](#log-messages) at various places in your code;
* Record [log messages](#log-messages) at various places in your code;
* Configure [log targets](#log-targets) in the application configuration to filter and export log messages;
* Configure [log targets](#log-targets) in the application configuration to filter and export log messages;
...
@@ -39,7 +39,7 @@ it will be exported as a string by calling [[yii\helpers\VarDumper::export()]].
...
@@ -39,7 +39,7 @@ it will be exported as a string by calling [[yii\helpers\VarDumper::export()]].
To better organize and filter log messages, it is recommended that you specify an appropriate category for each
To better organize and filter log messages, it is recommended that you specify an appropriate category for each
log message. You may choose a hierarchical naming scheme for categories, which will make it easier for
log message. You may choose a hierarchical naming scheme for categories, which will make it easier for
[log targets](#log-targets) to filter messages based on their categories. A simple yet effective naming scheme
[log targets](#log-targets) to filter messages based on their categories. A simple yet effective naming scheme
is to use the PHP magic constant `__METHOD__`as category names. This is also the approach used in the core
is to use the PHP magic constant `__METHOD__`for the category names. This is also the approach used in the core
Yii framework code. For example,
Yii framework code. For example,
```php
```php
...
@@ -47,7 +47,7 @@ Yii::trace('start calculating average revenue', __METHOD__);
...
@@ -47,7 +47,7 @@ Yii::trace('start calculating average revenue', __METHOD__);
```
```
The `__METHOD__` constant evaluates as the name of the method (prefixed with the fully qualified class name) where
The `__METHOD__` constant evaluates as the name of the method (prefixed with the fully qualified class name) where
the constant appears. For example, it equals to the string `'app\controllers\RevenueController::calculate'` if
the constant appears. For example, it is equal to the string `'app\controllers\RevenueController::calculate'` if
the above line of code is called within this method.
the above line of code is called within this method.
> Info: The logging methods described above are actually shortcuts to the [[yii\log\Logger::log()|log()]] method
> Info: The logging methods described above are actually shortcuts to the [[yii\log\Logger::log()|log()]] method
...
@@ -58,9 +58,9 @@ enough messages are logged or when the application ends, the logger object will
...
@@ -58,9 +58,9 @@ enough messages are logged or when the application ends, the logger object will
## Log Targets <a name="log-targets"></a>
## Log Targets <a name="log-targets"></a>
A log target is an instance of [[yii\log\Target]] class or its child class. It filters the log messages by their
A log target is an instance of the [[yii\log\Target]] class or its child class. It filters the log messages by their
severity levels and categories and then exports them to some medium. For example, a [[yii\log\DbTarget|database target]]
severity levels and categories and then exports them to some medium. For example, a [[yii\log\DbTarget|database target]]
exports the filtered log messages to a database table, while a [[yii\log\EmailTarget|email target]] exports
exports the filtered log messages to a database table, while an[[yii\log\EmailTarget|email target]] exports
the log messages to specified email addresses.
the log messages to specified email addresses.
You can register multiple log targets in an application by configuring them through the `log`[application component](structure-application-components.md)
You can register multiple log targets in an application by configuring them through the `log`[application component](structure-application-components.md)
...
@@ -169,7 +169,7 @@ under the categories whose names match either `yii\db\*` or `yii\web\HttpExcepti
...
@@ -169,7 +169,7 @@ under the categories whose names match either `yii\db\*` or `yii\web\HttpExcepti