Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b1ca4c71
Commit
b1ca4c71
authored
Oct 05, 2014
by
Nikola Basic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed typos and grammar errors
parent
1bea489f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
runtime-logging.md
docs/guide/runtime-logging.md
+9
-10
No files found.
docs/guide/runtime-logging.md
View file @
b1ca4c71
...
@@ -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
ed
used in the core
is to use the PHP magic constant
`__METHOD__`
as category names. This is also the approach used in the core
Yii framework code. For example,
Yii framework code. For example,
```
php
```
php
...
@@ -59,8 +59,8 @@ enough messages are logged or when the application ends, the logger object will
...
@@ -59,8 +59,8 @@ 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
[
[yii\log\Target
]
] class or its child class. It filters the log messages by their
severity levels and categories
, and then export
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
in
a database table, while a
[
[yii\log\EmailTarget|email target
]
] exports
exports the filtered log messages
to
a database table, while a
[
[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
You can register multiple log targets in an application by configuring them through the
`log`
application component
...
@@ -117,8 +117,7 @@ In the following, we will describe the features common to all log targets.
...
@@ -117,8 +117,7 @@ In the following, we will describe the features common to all log targets.
### Message Filtering <a name="message-filtering"></a>
### Message Filtering <a name="message-filtering"></a>
For each log target, you can configure its [[yii\log\Target::levels|levels]] and
For each log target, you can configure its [[yii\log\Target::levels|levels]] and
[[yii\log\Target::categories|categories]] properties to specify which severity levels and categories of the messages
[[yii\log\Target::categories|categories]] properties to specify which severity levels and categories of the messages the target should process.
that the target should process.
The [[yii\log\Target::levels|levels]] property takes an array consisting of one or several of the following values:
The [[yii\log\Target::levels|levels]] property takes an array consisting of one or several of the following values:
...
@@ -143,7 +142,7 @@ If you do not specify the [[yii\log\Target::categories|categories]] property, it
...
@@ -143,7 +142,7 @@ If you do not specify the [[yii\log\Target::categories|categories]] property, it
messages of *any* category.
messages of *any* category.
Besides whitelisting the categories by the [[yii\log\Target::categories|categories]] property, you may also
Besides whitelisting the categories by the [[yii\log\Target::categories|categories]] property, you may also
blacklist
ing
certain categories by the [[yii\log\Target::except|except]] property. If the category of a message
blacklist certain categories by the [[yii\log\Target::except|except]] property. If the category of a message
is found or matches one of the patterns in this property, it will NOT be processed by the target.
is found or matches one of the patterns in this property, it will NOT be processed by the target.
The following target configuration specifies that the target should only process error and warning messages
The following target configuration specifies that the target should only process error and warning messages
...
@@ -239,7 +238,7 @@ or when debugging an application.
...
@@ -239,7 +238,7 @@ or when debugging an application.
As aforementioned, log messages are maintained in an array by the [[yii\log\Logger|logger object]]. To limit the
As aforementioned, log messages are maintained in an array by the [[yii\log\Logger|logger object]]. To limit the
memory consumption by this array, the logger will flush the recorded messages to the [log targets](#log-targets)
memory consumption by this array, the logger will flush the recorded messages to the [log targets](#log-targets)
each time
when
the array accumulates certain number of log messages. You can customize this number by configuring
each time the array accumulates certain number of log messages. You can customize this number by configuring
the [[yii\log\Dispatcher::flushInterval|flushInterval]] property of the `
log
` component:
the [[yii\log\Dispatcher::flushInterval|flushInterval]] property of the `
log
` component:
...
@@ -271,7 +270,7 @@ property of individual [log targets](#log-targets), like the following,
...
@@ -271,7 +270,7 @@ property of individual [log targets](#log-targets), like the following,
Because of the flushing and exporting level setting, by default when you call `
Yii::trace()
` or any other logging
Because of the flushing and exporting level setting, by default when you call `
Yii::trace()
` or any other logging
method, you will NOT see the log message immediately in the log targets. This could be a problem for some long-running
method, you will NOT see the log message immediately in the log targets. This could be a problem for some long-running
console applications. To make each log message appear
ing
immediately in the log targets, you should set both
console applications. To make each log message appear immediately in the log targets, you should set both
[[yii\log\Dispatcher::flushInterval|flushInterval]] and [[yii\log\Target::exportInterval|exportInterval]] to be 1,
[[yii\log\Dispatcher::flushInterval|flushInterval]] and [[yii\log\Target::exportInterval|exportInterval]] to be 1,
like shown below:
like shown below:
...
@@ -340,7 +339,7 @@ Performance profiling is a special type of message logging that is used to measu
...
@@ -340,7 +339,7 @@ Performance profiling is a special type of message logging that is used to measu
code blocks and find out what are the performance bottlenecks. For example, the [[yii\db\Command]] class uses
code blocks and find out what are the performance bottlenecks. For example, the [[yii\db\Command]] class uses
performance profiling to find out the time taken by each DB query.
performance profiling to find out the time taken by each DB query.
To use performance profiling, first identi
ty the code bla
cks that need to be profiled. Then enclose each
To use performance profiling, first identi
fy the code blo
cks that need to be profiled. Then enclose each
code block like the following:
code block like the following:
```php
```php
...
@@ -372,6 +371,6 @@ For example,
...
@@ -372,6 +371,6 @@ For example,
If you miss `
\Y
ii::endProfile('block1')
` or switch the order of `
\Y
ii::endProfile('block1')
` and
If you miss `
\Y
ii::endProfile('block1')
` or switch the order of `
\Y
ii::endProfile('block1')
` and
`
\Y
ii::endProfile('block2')
`, the performance profiling will not work.
`
\Y
ii::endProfile('block2')
`, the performance profiling will not work.
For each code block being profiled, a log message
at
the severity level `
profile
`
is recorded. You can configure
For each code block being profiled, a log message
with
the severity level `
profile
`
is recorded. You can configure
a
[
log target
](
#log-targets
)
to collect such messages and export them. The
[
Yii debugger
](
tool-debugger.md
)
has
a
[
log target
](
#log-targets
)
to collect such messages and export them. The
[
Yii debugger
](
tool-debugger.md
)
has
a built-in performance profiling panel showing the profiling results.
a built-in performance profiling panel showing the profiling results.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment