opt: lucene日志
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package org.nl.common.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: lyd
|
||||||
|
* @Description: 配置文件获取方法
|
||||||
|
* @Date: 2023/12/6
|
||||||
|
*/
|
||||||
|
public class YmlConfigFileUtil {
|
||||||
|
public static Properties readConfig(String configFile) {
|
||||||
|
// 创建 Resource 对象
|
||||||
|
Resource resource = new ClassPathResource(configFile);
|
||||||
|
|
||||||
|
// 创建 YamlPropertiesFactoryBean
|
||||||
|
YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
|
||||||
|
yamlPropertiesFactoryBean.setResources(resource);
|
||||||
|
|
||||||
|
// 获取 Properties 对象
|
||||||
|
Properties properties = yamlPropertiesFactoryBean.getObject();
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,11 +16,13 @@ import org.apache.lucene.index.IndexWriter;
|
|||||||
import org.apache.lucene.index.IndexWriterConfig;
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.FSDirectory;
|
import org.apache.lucene.store.FSDirectory;
|
||||||
|
import org.nl.common.utils.YmlConfigFileUtil;
|
||||||
import org.wltea.analyzer.lucene.IKAnalyzer;
|
import org.wltea.analyzer.lucene.IKAnalyzer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
||||||
|
|
||||||
@@ -32,7 +34,11 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
|||||||
public void start() {
|
public void start() {
|
||||||
super.start();
|
super.start();
|
||||||
try {
|
try {
|
||||||
index = FSDirectory.open(Paths.get(LogMessageConstant.INDEX_DIR));
|
// 读取配置文件
|
||||||
|
Properties properties = YmlConfigFileUtil.readConfig("config/application.yml");
|
||||||
|
|
||||||
|
String luceneDir = properties.getProperty("lucene.index.path");
|
||||||
|
index = FSDirectory.open(Paths.get(luceneDir));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,5 +80,7 @@ public class MdBaseBrickInfo implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "工单号")
|
@ApiModelProperty(value = "工单号")
|
||||||
private String workorder_code;
|
private String workorder_code;
|
||||||
|
@ApiModelProperty(value = "故障原因")
|
||||||
|
private String error_cause;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public class MdBaseBrickInfoServiceImpl extends ServiceImpl<MdBaseBrickInfoMappe
|
|||||||
brickInfo.setFlatness(dto.getFlatness());
|
brickInfo.setFlatness(dto.getFlatness());
|
||||||
brickInfo.setUnqualified_qty(dto.getUnqualified_qty());
|
brickInfo.setUnqualified_qty(dto.getUnqualified_qty());
|
||||||
brickInfo.setIs_group(false);
|
brickInfo.setIs_group(false);
|
||||||
|
brickInfo.setError_cause(dto.getError_cause());
|
||||||
return brickInfo;
|
return brickInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,4 +42,6 @@ public class BrickInfoDto extends BaseRequest {
|
|||||||
private String flatness;
|
private String flatness;
|
||||||
/** 缺陷个数 **/
|
/** 缺陷个数 **/
|
||||||
private String unqualified_qty;
|
private String unqualified_qty;
|
||||||
|
/** 故障原因 */
|
||||||
|
private String error_cause;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,3 @@ sa-token:
|
|||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
|
|
||||||
lucene:
|
|
||||||
index:
|
|
||||||
path: D:\lucene\index
|
|
||||||
|
|||||||
@@ -172,6 +172,3 @@ sa-token:
|
|||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lucene:
|
|
||||||
index:
|
|
||||||
path: E:\lucene\index
|
|
||||||
|
|||||||
@@ -129,3 +129,7 @@ mybatis-plus:
|
|||||||
global-config:
|
global-config:
|
||||||
db-config:
|
db-config:
|
||||||
id-type: INPUT
|
id-type: INPUT
|
||||||
|
|
||||||
|
lucene:
|
||||||
|
index:
|
||||||
|
path: D:\lucene\index
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<!-- <charset>${log.charset}</charset>-->
|
<!-- <charset>${log.charset}</charset>-->
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
<appender name="luceneAppender" class="org.nl.config.lucene.LuceneAppender" >
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>DEBUG</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
||||||
<property name="LOG_HOME" value="${logPath}"/>
|
<property name="LOG_HOME" value="${logPath}"/>
|
||||||
@@ -62,9 +69,9 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
</appender>
|
</appender>
|
||||||
<!--开发环境:打印控制台-->
|
<!--开发环境:打印控制台-->
|
||||||
<springProfile name="dev">
|
<springProfile name="dev">
|
||||||
<root level="INFO">
|
<root level="DEBUG">
|
||||||
<appender-ref ref="CONSOLE"/>
|
|
||||||
<appender-ref ref="asyncLuceneAppender"/>
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
</root>
|
</root>
|
||||||
<logger name="org.springframework" level="ERROR" additivity="false">
|
<logger name="org.springframework" level="ERROR" additivity="false">
|
||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
@@ -107,7 +114,7 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
|
|
||||||
<!--生产环境:打印控制台和输出到文件-->
|
<!--生产环境:打印控制台和输出到文件-->
|
||||||
<springProfile name="prod">
|
<springProfile name="prod">
|
||||||
<root level="INFO">
|
<root level="DEBUG">
|
||||||
<appender-ref ref="asyncFileAppender"/>
|
<appender-ref ref="asyncFileAppender"/>
|
||||||
<appender-ref ref="asyncLuceneAppender"/>
|
<appender-ref ref="asyncLuceneAppender"/>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
Reference in New Issue
Block a user