PHP Class yii\log\Dispatcher

Dispatcher implements the Dispatcher::dispatch-method that forwards the log messages from a Logger to the registered log [[targets]]. An instance of Dispatcher is registered as a core application component and can be accessed using Yii::$app->log. You may configure the targets in application configuration, like the following: php [ 'components' => [ 'log' => [ 'targets' => [ 'file' => [ 'class' => 'yii\log\FileTarget', 'levels' => ['trace', 'info'], 'categories' => ['yii\*'], ], 'email' => [ 'class' => 'yii\log\EmailTarget', 'levels' => ['error', 'warning'], 'message' => [ 'to' => '[email protected]', ], ], ], ], ], ] Each log target can have a name and can be referenced via the [[targets]] property as follows: php Yii::$app->log->targets['file']->enabled = false;
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\Component
Datei anzeigen Open project: yiisoft/yii2

Public Properties

Property Type Description
$targets the log targets. Each array element represents a single [[Target|log target]] instance or the configuration for creating the log target instance.

Public Methods

Method Description
__construct ( $config = [] )
dispatch ( array $messages, boolean $final ) Dispatches the logged messages to [[targets]].
getFlushInterval ( ) : integer
getLogger ( ) : Logger Gets the connected logger.
getTraceLevel ( ) : integer
init ( )
setFlushInterval ( integer $value )
setLogger ( Logger | string | array $value ) Sets the connected logger.
setTraceLevel ( integer $value )

Method Details

__construct() public method

public __construct ( $config = [] )

dispatch() public method

Dispatches the logged messages to [[targets]].
public dispatch ( array $messages, boolean $final )
$messages array the logged messages
$final boolean whether this method is called at the end of the current application

getFlushInterval() public method

public getFlushInterval ( ) : integer
return integer how many messages should be logged before they are sent to targets. This method returns the value of [[Logger::flushInterval]].

getLogger() public method

If not set, [[\Yii::getLogger()]] will be used.
public getLogger ( ) : Logger
return Logger the logger.

getTraceLevel() public method

public getTraceLevel ( ) : integer
return integer how many application call stacks should be logged together with each message. This method returns the value of [[Logger::traceLevel]]. Defaults to 0.

init() public method

public init ( )

setFlushInterval() public method

public setFlushInterval ( integer $value )
$value integer how many messages should be logged before they are sent to targets. This method will set the value of [[Logger::flushInterval]]. Defaults to 1000, meaning the [[Logger::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 [[Logger::flush()]].

setLogger() public method

Sets the connected logger.
public setLogger ( Logger | string | array $value )
$value Logger | string | array the logger to be used. This can either be a logger instance or a configuration that will be used to create one using [[Yii::createObject()]].

setTraceLevel() public method

public setTraceLevel ( integer $value )
$value integer how many application call stacks should be logged together with each message. This method will set the value of [[Logger::traceLevel]]. If the value is greater than 0, at most that number of call stacks will be logged. Note that only application call stacks are counted. Defaults to 0.

Property Details

$targets public_oe property

the log targets. Each array element represents a single [[Target|log target]] instance or the configuration for creating the log target instance.
public $targets