[关闭]
@liyuj 2018-04-27T10:06:25.000000Z 字数 1605 阅读 1795

LuceneAppender

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:

  1. <Lucene name="lucene" ignoreExceptions="true" target="/target/lucene/index" expiryTime=“1296000”>
  2. <IndexField name="seq" pattern="$${ctx:seq}"/>
  3. <IndexField name="time" pattern="%d{UNIX_MILLIS}" type = "Long"/>
  4. <IndexField name="level" pattern="%-5level" />
  5. <IndexField name="content" pattern="%class{36} %L %M - %msg%xEx%n" />
  6. </Lucene>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注