mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
feat: 增加 HTTP 请求和响应的日志记录
This commit is contained in:
parent
d63be23aca
commit
c46864bbb6
6
pom.xml
6
pom.xml
@ -25,6 +25,7 @@
|
|||||||
<redisson.version>3.19.1</redisson.version>
|
<redisson.version>3.19.1</redisson.version>
|
||||||
<spring-boot-admin.version>3.0.0-M1</spring-boot-admin.version>
|
<spring-boot-admin.version>3.0.0-M1</spring-boot-admin.version>
|
||||||
<springdoc-openapi.version>2.5.0</springdoc-openapi.version>
|
<springdoc-openapi.version>2.5.0</springdoc-openapi.version>
|
||||||
|
<logbook.version>3.9.0</logbook.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -204,6 +205,11 @@
|
|||||||
<groupId>org.flywaydb</groupId>
|
<groupId>org.flywaydb</groupId>
|
||||||
<artifactId>flyway-mysql</artifactId>
|
<artifactId>flyway-mysql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.zalando</groupId>
|
||||||
|
<artifactId>logbook-spring-boot-starter</artifactId>
|
||||||
|
<version>${logbook.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package io.github.xxyopen.novel.core.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.zalando.logbook.Logbook;
|
||||||
|
|
||||||
|
import static org.zalando.logbook.core.Conditions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logbook 配置
|
||||||
|
*
|
||||||
|
* @author xiongxiaoyang
|
||||||
|
* @date 2024/9/13
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class LogbookConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Logbook logbook() {
|
||||||
|
return Logbook.builder()
|
||||||
|
.condition(exclude(
|
||||||
|
// 忽略 OPTIONS 请求
|
||||||
|
requestWithMethod("OPTIONS"),
|
||||||
|
// 忽略 /actuator 以及其子路径(Spring Boot Actuator 提供的端点)的请求
|
||||||
|
requestTo("/actuator/**"),
|
||||||
|
// 忽略 Swagger 文档路径
|
||||||
|
requestTo("/swagger-ui/**"),
|
||||||
|
requestTo("/v3/api-docs/**"),
|
||||||
|
// 忽略二进制文件请求
|
||||||
|
contentType("application/octet-stream"),
|
||||||
|
// 忽略文件上传请求
|
||||||
|
contentType("multipart/form-data")
|
||||||
|
))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -30,7 +30,7 @@ server:
|
|||||||
--- #---------------------数据库配置---------------------------
|
--- #---------------------数据库配置---------------------------
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://localhost:3306/novel_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://localhost:3306/novel?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: test123456
|
password: test123456
|
||||||
# ShardingSphere-JDBC 配置
|
# ShardingSphere-JDBC 配置
|
||||||
@ -229,6 +229,19 @@ spring:
|
|||||||
class: javax.net.ssl.SSLSocketFactory
|
class: javax.net.ssl.SSLSocketFactory
|
||||||
fallback: false
|
fallback: false
|
||||||
|
|
||||||
|
--- #----------------------Logbook配置-----------------------------
|
||||||
|
logbook:
|
||||||
|
format:
|
||||||
|
# 输出格式
|
||||||
|
style: http
|
||||||
|
obfuscate:
|
||||||
|
headers:
|
||||||
|
# 隐藏 Authorization 头信息
|
||||||
|
- Authorization
|
||||||
|
parameters:
|
||||||
|
# 隐藏密码参数
|
||||||
|
- password
|
||||||
|
|
||||||
--- #---------------------自定义配置----------------------------
|
--- #---------------------自定义配置----------------------------
|
||||||
novel:
|
novel:
|
||||||
# 跨域配置
|
# 跨域配置
|
||||||
@ -237,7 +250,7 @@ novel:
|
|||||||
allow-origins:
|
allow-origins:
|
||||||
- http://localhost:1024
|
- http://localhost:1024
|
||||||
- http://localhost:8080
|
- http://localhost:8080
|
||||||
# JWT密钥
|
# JWT 密钥
|
||||||
jwt:
|
jwt:
|
||||||
secret: E66559580A1ADF48CDD928516062F12E
|
secret: E66559580A1ADF48CDD928516062F12E
|
||||||
# XSS 过滤配置
|
# XSS 过滤配置
|
||||||
|
@ -62,6 +62,10 @@
|
|||||||
<appender-ref ref="STDOUT"/>
|
<appender-ref ref="STDOUT"/>
|
||||||
<appender-ref ref="FILE"/>
|
<appender-ref ref="FILE"/>
|
||||||
</logger>
|
</logger>
|
||||||
|
<logger name="org.zalando.logbook" level="TRACE" additivity="false">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</logger>
|
||||||
</springProfile>
|
</springProfile>
|
||||||
|
|
||||||
<springProfile name="prod">
|
<springProfile name="prod">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user