|
|
@ -13,6 +13,7 @@ import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.ttl.TransmittableThreadLocal; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import org.apache.lucene.analysis.Analyzer; |
|
|
|
import org.apache.lucene.document.Document; |
|
|
|
import org.apache.lucene.document.Field; |
|
|
@ -69,13 +70,16 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
@Override |
|
|
|
protected void append(ILoggingEvent event) { |
|
|
|
String message = event.getFormattedMessage(); |
|
|
|
|
|
|
|
try { |
|
|
|
String[] split = message.split("@"); |
|
|
|
LuceneLogDto luceneLogDto = JSONObject.parseObject(split[1], LuceneLogDto.class); |
|
|
|
LuceneLogDto luceneLogDto = JSONObject.parseObject(split[0], LuceneLogDto.class); |
|
|
|
Document document = new Document(); |
|
|
|
try { |
|
|
|
System.out.println("---lucene----"); |
|
|
|
//向document对象中添加域。
|
|
|
|
Map<String, String> mdcPropertyMap = event.getMDCPropertyMap(); |
|
|
|
String traceId = mdcPropertyMap.get("traceId"); |
|
|
@ -121,9 +125,11 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> { |
|
|
|
indexWriter.addDocument(document); |
|
|
|
indexWriter.commit(); |
|
|
|
} catch (IOException e) { |
|
|
|
indexWriter.commit(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|