@liyuj
2018-04-27T18:06:25.000000Z
字数 1605
阅读 1959
The LuceneAppender
writes log events to a lucene index library.In the lucene index library,specifically, what Field does each Document contain, configured by IndexField
.
In order to improve performance, at present commit once every minute, rather than every logging event.In addition, in order to prevent Lucene index library from taking too much disk space, an optional expiryTime
parameter is provided to periodically clean the lucene.
At present, depending on the version of Lucene, two different LuceneAppender, Lucene5Appender and Lucene7Appender, are provided.
After logging, you can query log message through Lucene's API.
LuceneAppender parameters
Parameter Name | Type | Description |
---|---|---|
name |
String | The name of the Appender. |
ignoreExceptions |
boolean | The default is true , causing exceptions encountered while appending events to be internally logged and then ignored. When set to false exceptions will be propagated to the caller, instead. You must set this to false when wrapping this Appender in a FailoverAppender. |
target |
String | Lucene index library path. |
expiryTime |
Integer | optional,expiration time(second),every day at zero will clear up the data before the expiration time. |
IndexField parameters
Parameter Name | Type | Description |
---|---|---|
name |
String | the field name in the lucene index document. |
pattern |
String | the same as PatternLayout's pattern attribute. |
type |
String | optional,document field type,optional values include Long , String ,and Text (default), |
Here is a sample Lucene configuration:
<Lucene name="lucene" ignoreExceptions="true" target="/target/lucene/index" expiryTime=“1296000”>
<IndexField name="seq" pattern="$${ctx:seq}"/>
<IndexField name="time" pattern="%d{UNIX_MILLIS}" type = "Long"/>
<IndexField name="level" pattern="%-5level" />
<IndexField name="content" pattern="%class{36} %L %M - %msg%xEx%n" />
</Lucene>