feat: logback-elasticsearch-appender存储日志到es中,搭配grafana使用
This commit is contained in:
BIN
nladmin-system/doc/grafana使用截图.png
Normal file
BIN
nladmin-system/doc/grafana使用截图.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
@@ -32,6 +32,12 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- logback appender日志-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.internetitem</groupId>
|
||||||
|
<artifactId>logback-elasticsearch-appender</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dameng</groupId>
|
<groupId>com.dameng</groupId>
|
||||||
<artifactId>DmJdbcDriver18</artifactId>
|
<artifactId>DmJdbcDriver18</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.nl;
|
package org.nl;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
|
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @author ldjun
|
* @author ldjun
|
||||||
* @date 2021/2/22 9:20:19
|
* @date 2021/2/22 9:20:19
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@RestController
|
@RestController
|
||||||
@SpringBootApplication(exclude = {
|
@SpringBootApplication(exclude = {
|
||||||
@@ -54,6 +56,7 @@ public class AppRun implements ApplicationRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("noblelift - 项目启动成功!");
|
||||||
System.out.println("项目启动成功!");
|
System.out.println("项目启动成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ nl:
|
|||||||
username: root
|
username: root
|
||||||
password: 12356
|
password: 12356
|
||||||
database: nl-platform
|
database: nl-platform
|
||||||
|
es:
|
||||||
|
address: http://127.0.0.1:9200
|
||||||
redis:
|
redis:
|
||||||
ip: 127.0.0.1
|
ip: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ lucene:
|
|||||||
index:
|
index:
|
||||||
path: D:\lucene2\index
|
path: D:\lucene2\index
|
||||||
spring:
|
spring:
|
||||||
|
elasticsearch:
|
||||||
|
rest:
|
||||||
|
uris: ${nl.config.es.address}
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
autoconfigure:
|
autoconfigure:
|
||||||
@@ -89,6 +92,12 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
repositories:
|
repositories:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
elasticsearch:
|
||||||
|
repositories:
|
||||||
|
enabled: true
|
||||||
|
client:
|
||||||
|
reactive:
|
||||||
|
endpoints: ${nl.config.es.address}
|
||||||
redis:
|
redis:
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
host: ${REDIS_HOST:${nl.config.redis.ip}}
|
host: ${REDIS_HOST:${nl.config.redis.ip}}
|
||||||
@@ -279,3 +288,7 @@ sa-token:
|
|||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
|
management:
|
||||||
|
health:
|
||||||
|
elasticsearch:
|
||||||
|
enabled: false
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<property name="log.charset" value="utf-8"/>
|
<property name="log.charset" value="utf-8"/>
|
||||||
<property name="log.pattern"
|
<property name="log.pattern"
|
||||||
value="%cyan(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %cyan(%msg%n)"/>
|
value="%cyan(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %cyan(%msg%n)"/>
|
||||||
|
<springProperty scope="context" name="esPath" source="nl.config.es.address" defaultValue="http://127.0.0.1:9200"/>
|
||||||
<property name="LOG_HOME" value="${logPath}"/>
|
<property name="LOG_HOME" value="${logPath}"/>
|
||||||
|
<property name="ES_HOME" value="${esPath}"/>
|
||||||
<!--引入默认的一些设置-->
|
<!--引入默认的一些设置-->
|
||||||
<!--<include resource="log/XrToMes.xml"/>
|
<!--<include resource="log/XrToMes.xml"/>
|
||||||
<include resource="log/MesToErp.xml"/>-->
|
<include resource="log/MesToErp.xml"/>-->
|
||||||
@@ -80,10 +82,58 @@ https://juejin.cn/post/6844903775631572999
|
|||||||
<queueSize>500</queueSize>
|
<queueSize>500</queueSize>
|
||||||
<appender-ref ref="FILE"/>
|
<appender-ref ref="FILE"/>
|
||||||
</appender>
|
</appender>
|
||||||
|
<appender name="ELASTIC" class="com.internetitem.logback.elasticsearch.ElasticsearchAppender">
|
||||||
|
<url>http://127.0.0.1:9200/_bulk</url>
|
||||||
|
<index>nl_lms</index>
|
||||||
|
<type>sever</type>
|
||||||
|
<loggerName>es-logger</loggerName> <!-- optional -->
|
||||||
|
<errorLoggerName>es-error-logger</errorLoggerName> <!-- optional -->
|
||||||
|
<connectTimeout>30000</connectTimeout> <!-- optional (in ms, default 30000) -->
|
||||||
|
<errorsToStderr>false</errorsToStderr> <!-- optional (default false) -->
|
||||||
|
<includeCallerData>false</includeCallerData> <!-- optional (default false) -->
|
||||||
|
<logsToStderr>false</logsToStderr> <!-- optional (default false) -->
|
||||||
|
<maxQueueSize>30000</maxQueueSize> <!-- optional (default 104857600) -->
|
||||||
|
<maxRetries>3</maxRetries> <!-- optional (default 3) -->
|
||||||
|
<readTimeout>30000</readTimeout> <!-- optional (in ms, default 30000) -->
|
||||||
|
<sleepTime>250</sleepTime> <!-- optional (in ms, default 250) -->
|
||||||
|
<rawJsonMessage>false</rawJsonMessage> <!-- optional (default false) -->
|
||||||
|
<includeMdc>true</includeMdc> <!-- optional (default false) -->
|
||||||
|
<maxMessageSize>-1</maxMessageSize> <!-- optional (default -1 -->
|
||||||
|
<authentication class="com.internetitem.logback.elasticsearch.config.BasicAuthentication" /> <!-- optional -->
|
||||||
|
<properties>
|
||||||
|
<property>
|
||||||
|
<name>host</name>
|
||||||
|
<value>127.0.0.1</value>
|
||||||
|
<allowEmpty>true</allowEmpty>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>severity</name>
|
||||||
|
<value>%level</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>thread</name>
|
||||||
|
<value>%thread</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>stacktrace</name>
|
||||||
|
<value>%ex</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>logger</name>
|
||||||
|
<value>%logger</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<headers>
|
||||||
|
<header>
|
||||||
|
<name>Content-Type</name>
|
||||||
|
<value>application/json</value>
|
||||||
|
</header>
|
||||||
|
</headers>
|
||||||
|
</appender>
|
||||||
<!--开发环境:打印控制台-->
|
<!--开发环境:打印控制台-->
|
||||||
<springProfile name="dev">
|
<springProfile name="dev">
|
||||||
<root level="debug">
|
<root level="info">
|
||||||
<appender-ref ref="asyncLuceneAppender"/>
|
<appender-ref ref="ELASTIC"/>
|
||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
</root>
|
</root>
|
||||||
<logger name="com.baomidou.mybatisplus.core.MybatisConfiguration" level="ERROR" additivity="false">
|
<logger name="com.baomidou.mybatisplus.core.MybatisConfiguration" level="ERROR" additivity="false">
|
||||||
|
|||||||
Reference in New Issue
Block a user