rev:日志文件打印慢
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user