rev:日志文件打印慢

This commit is contained in:
zhangzq
2023-12-21 19:21:08 +08:00
parent 41040484b5
commit 2bdea65231
15 changed files with 106 additions and 63 deletions

View File

@@ -3,6 +3,7 @@ package org.nl.modules.lucene.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@@ -37,14 +38,20 @@ public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService {
@SneakyThrows
@Override
public void deviceExecuteLog(LuceneLogDto luceneLogDto) {
luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
addIndex(luceneLogDto);
if (luceneLogDto!=null){
log.info("log:{}", JSON.toJSONString(luceneLogDto));
}
// luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
// addIndex(luceneLogDto);
}
@Override
public void interfaceExecuteLog(LuceneLogDto luceneLogDto) throws IOException {
luceneLogDto.setLogType(LogTypeEnum.INTERFACE_LOG.getDesc());
addIndex(luceneLogDto);
if (luceneLogDto!=null){
log.info("log:{}", JSON.toJSONString(luceneLogDto));
}
// luceneLogDto.setLogType(LogTypeEnum.INTERFACE_LOG.getDesc());
// addIndex(luceneLogDto);
}
private void addIndex(LuceneLogDto luceneLogDto) throws IOException {
@@ -82,6 +89,7 @@ public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService {
long endTime = System.currentTimeMillis();
log.info("建立索引共耗时{}毫秒", endTime - startTime);
indexWriter.commit();
indexWriter.close();
// MDC.put("DEVICECODE", luceneLogDto.getDevice_code());
} catch (Exception e) {
log.error(e.getMessage(), e);