|继承||yii\log\Logger » yii\base\Component » yii\base\BaseObject|
Logger records logged messages in memory and sends them to different targets if $dispatcher is set.
A Logger instance can be accessed via
Yii::getLogger(). You can call the method log() to record a single log message.
For convenience, a set of shortcut methods are provided for logging messages of various severity levels
via the Yii class:
For more details and usage information on Logger, see the guide article on logging.
|$dbProfiling||array||The first element indicates the number of SQL statements executed, and the second element the total time spent in SQL execution. This property is read-only.||yii\log\Logger|
|$dispatcher||yii\log\Dispatcher||The message dispatcher||yii\log\Logger|
|$elapsedTime||float||The total elapsed time in seconds for current request. This property is read-only.||yii\log\Logger|
|$flushInterval||integer||How many messages should be logged before they are flushed from memory and sent to targets.||yii\log\Logger|
|$profiling||array||The profiling results. Each element is an array consisting of these
|$traceLevel||integer||How much call stack information (file name and line number) should be logged for each message.||yii\log\Logger|
|LEVEL_ERROR||1||Error message level. An error message is one that indicates the abnormal termination of the application and may require developer's handling.||yii\log\Logger|
|LEVEL_INFO||4||Informational message level. An informational message is one that includes certain information for developers to review.||yii\log\Logger|
|LEVEL_PROFILE||64||Profiling message level. This indicates the message is for profiling purpose.||yii\log\Logger|
|LEVEL_PROFILE_BEGIN||80||Profiling message level. This indicates the message is for profiling purpose. It marks the beginning of a profiling block.||yii\log\Logger|
|LEVEL_PROFILE_END||96||Profiling message level. This indicates the message is for profiling purpose. It marks the end of a profiling block.||yii\log\Logger|
|LEVEL_TRACE||8||Tracing message level. An tracing message is one that reveals the code execution flow.||yii\log\Logger|
|LEVEL_WARNING||2||Warning message level. A warning message is one that indicates some abnormal happens but the application is able to continue to run. Developers should pay attention to this message.||yii\log\Logger|
The first element indicates the number of SQL statements executed, and the second element the total time spent in SQL execution. This property is read-only.
The message dispatcher
The total elapsed time in seconds for current request. This property is read-only.
How many messages should be logged before they are flushed from memory and sent to targets. Defaults to 1000, meaning the flush() method will be invoked once every 1000 messages logged. Set this property to be 0 if you don't want to flush messages until the application terminates. This property mainly affects how much memory will be taken by the logged messages. A smaller value means less memory, but will increase the execution time due to the overhead of flush().
[  => message (mixed, can be a string or some complex data, such as an exception object)  => level (integer)  => category (string)  => timestamp (float, obtained by microtime(true))  => traces (array, debug backtrace, contains the application code call stacks)  => memory usage in bytes (int, obtained by memory_get_usage()), available since version 2.0.11. ]
The profiling results. Each element is an array consisting of these
memoryDiff values are available since version 2.0.11. This property is read-only.
How much call stack information (file name and line number) should be logged for each message. If it is greater than 0, at most that number of call stacks will be logged. Note that only application call stacks are counted.
Calculates the elapsed time for the given log messages.
|public array calculateTimings ( $messages )|
The log messages obtained from profiling
Timings. Each element is an array consisting of these elements:
Flushes log messages from memory to targets.
|public void flush ( $final = false )|
Whether this is a final call during a request.
Returns the statistical results of DB queries.
The results returned include the number of SQL statements executed and the total time spent.
|public array getDbProfiling ( )|
The first element indicates the number of SQL statements executed, and the second element the total time spent in SQL execution.
Returns the total elapsed time since the start of the current request.
This method calculates the difference between now and the timestamp
defined by constant
YII_BEGIN_TIME which is evaluated at the beginning
of yii\BaseYii class file.
|public float getElapsedTime ( )|
The total elapsed time in seconds for current request.
Returns the text display of the specified level.
|public static string getLevelName ( $level )|
The text display of the level
Returns the profiling results.
By default, all profiling results will be returned. You may provide
$excludeCategories as parameters to retrieve the
results that you are interested in.
|public array getProfiling ( $categories = , $excludeCategories =  )|
List of categories that you are interested in. You can use an asterisk at the end of a category to do a prefix match. For example, 'yii\db*' will match categories starting with 'yii\db\', such as 'yii\db\Connection'.
List of categories that you want to exclude
The profiling results. Each element is an array consisting of these elements:
Initializes the logger by registering flush() as a shutdown function.
|public void init ( )|
Logs a message with the given type and category.
If $traceLevel is greater than 0, additional call stack information about the application code will be logged as well.
|public void log ( $message, $level, $category = 'application' )|
The message to be logged. This can be a simple string or a more complex data structure that will be handled by a log target.
The level of the message. This must be one of the following:
The category of the message.