fix: lucene打印

This commit is contained in:
2024-08-09 18:03:17 +08:00
parent 4db3a16a36
commit d0101952d2
2 changed files with 7 additions and 21 deletions

View File

@@ -88,23 +88,6 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> {
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, traceId, Field.Store.YES));
doc.add(new StringField(LogMessageConstant.FIELD_LABEL, ObjectUtil.isNotEmpty(mdcPropertyMap.get("tag_name"))
? mdcPropertyMap.get("tag_name") : "-", Field.Store.YES));
} else {
// 定义正则表达式匹配17位数字
String regex = "\\d{17}";
// 创建 Pattern 对象
Pattern pattern = Pattern.compile(regex);
// 创建 Matcher 对象
Matcher matcher = pattern.matcher(message);
String matchedNumber = null;
// 查找匹配的数字
while (matcher.find()) {
matchedNumber = matcher.group();
}
if (ObjectUtil.isNotEmpty(matchedNumber)) {
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, matchedNumber, Field.Store.YES));
} else {
doc.add(new StringField(LogMessageConstant.FIELD_TRACEID, "无生成链路ID", Field.Store.YES));
}
}
doc.add(new TextField(LogMessageConstant.FIELD_MESSAGE, message, Field.Store.YES));
try {

View File

@@ -1,19 +1,21 @@
package org.nl.system.service.quartz.utils;
import cn.hutool.core.util.StrUtil;
import com.yomahub.tlog.core.thread.TLogInheritableTask;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.config.SpringContextHolder;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
/**
* 执行定时任务
*
* @author /
*/
@Slf4j
public class QuartzRunnable implements Callable {
public class QuartzRunnable extends TLogInheritableTask {
private final Object target;
private final Method method;
@@ -31,14 +33,15 @@ public class QuartzRunnable implements Callable {
}
}
@SneakyThrows
@Override
public Object call() throws Exception {
public void runTask() {
ReflectionUtils.makeAccessible(method);
if (StrUtil.isNotEmpty(params)) {
method.invoke(target, params);
} else {
method.invoke(target);
}
return null;
}
}