Class yii\elasticsearch\ElasticsearchTarget
Inheritance | yii\elasticsearch\ElasticsearchTarget » yii\log\Target |
---|---|
Available since version | 2.0.5 |
ElasticsearchTarget stores log messages in a elasticsearch index.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$cacheContext | boolean | If true, context message will cached once it's been created. | yii\elasticsearch\ElasticsearchTarget |
$db | yii\elasticsearch\Connection|array|string | The elasticsearch connection object or the application component ID of the elasticsearch connection. | yii\elasticsearch\ElasticsearchTarget |
$includeContext | boolean | If true, context will be included in every message. | yii\elasticsearch\ElasticsearchTarget |
$index | string | Elasticsearch index name. | yii\elasticsearch\ElasticsearchTarget |
$logContext | boolean | If true, context will be logged as a separate message after all other messages. | yii\elasticsearch\ElasticsearchTarget |
$options | array | URL options. | yii\elasticsearch\ElasticsearchTarget |
$type | string | Elasticsearch type name. | yii\elasticsearch\ElasticsearchTarget |
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$_contextMessage | string | Context message cache (can be used multiple times if context is appended to every message) | yii\elasticsearch\ElasticsearchTarget |
Public Methods
Method | Description | Defined By |
---|---|---|
collect() | Processes the given log messages. | yii\elasticsearch\ElasticsearchTarget |
export() | yii\elasticsearch\ElasticsearchTarget | |
init() | This method will initialize the \yii\elasticsearch\elasticsearch property to make sure it refers to a valid Elasticsearch connection. | yii\elasticsearch\ElasticsearchTarget |
prepareMessage() | Prepares a log message. | yii\elasticsearch\ElasticsearchTarget |
Protected Methods
Method | Description | Defined By |
---|---|---|
getContextMessage() | If $includeContext property is false, returns context message normally. | yii\elasticsearch\ElasticsearchTarget |
Property Details
Context message cache (can be used multiple times if context is appended to every message)
If true, context message will cached once it's been created. Makes sense to use with $includeContext.
The elasticsearch connection object or the application component ID of the elasticsearch connection.
If true, context will be included in every message. This is convenient if you log application errors and analyze them with tools like Kibana.
Elasticsearch index name.
If true, context will be logged as a separate message after all other messages.
URL options.
Elasticsearch type name.
Method Details
Processes the given log messages.
This method will filter the given messages with \yii\elasticsearch\levels and \yii\elasticsearch\categories. And if requested, it will also export the filtering result to specific medium (e.g. email). Depending on the $includeContext attribute, a context message will be either created or ignored.
public void collect ( $messages, $final ) | ||
$messages | array | Log messages to be processed. See \yii\log\Logger::messages for the structure of each message. |
$final | boolean | Whether this method is called at the end of the current application |
public void export ( ) |
If $includeContext property is false, returns context message normally.
If $includeContext is true, returns an empty string (so that context message in collect() is not generated), expecting that context will be appended to every message in prepareMessage().
protected array getContextMessage ( ) | ||
return | array | The context information |
---|
This method will initialize the \yii\elasticsearch\elasticsearch property to make sure it refers to a valid Elasticsearch connection.
public void init ( ) | ||
throws | \yii\base\InvalidConfigException | if \yii\elasticsearch\elasticsearch is invalid. |
---|
Prepares a log message.
public string prepareMessage ( $message ) | ||
$message | array | The log message to be formatted. |