mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-14 13:50:25 +00:00
feat 日志模块
This commit is contained in:
@@ -3,7 +3,7 @@ package cn.bootx.platform.common.cache.configuration;
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
26
bootx-platform/bootx-platform-common/common-log/pom.xml
Normal file
26
bootx-platform/bootx-platform-common/common-log/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>bootx-platform-common</artifactId>
|
||||
<version>3.0.0.beta1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-log</artifactId>
|
||||
<description>日志模块</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,17 @@
|
||||
package cn.bootx.platform.common.log;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 日志扫描
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2022/6/6
|
||||
*/
|
||||
@ComponentScan
|
||||
@ConfigurationPropertiesScan
|
||||
@AutoConfiguration
|
||||
public class LogAutoConfigurationLogAutoConfiguration {
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package cn.bootx.platform.common.log.handler;
|
||||
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 针对请求生成链路追踪ID
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/4/20
|
||||
*/
|
||||
@Order(value = Integer.MIN_VALUE)
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
public class LogTraceHeaderHolderFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
String traceId = RandomUtil.randomString(12);
|
||||
// 添加普通日志 TraceId
|
||||
MDC.put(CommonCode.TRACE_ID, traceId);
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
finally {
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1 @@
|
||||
cn.bootx.platform.common.log.LogAutoConfigurationLogAutoConfiguration
|
@@ -23,6 +23,7 @@
|
||||
<module>common-header-holder</module>
|
||||
<module>common-redis</module>
|
||||
<module>common-cache</module>
|
||||
<module>common-log</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
Reference in New Issue
Block a user