修改日志打印
This commit is contained in:
@ -7,7 +7,9 @@ import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
@ -25,7 +27,7 @@ import java.nio.charset.StandardCharsets;
|
||||
* 适用于 Spring Boot 2.3.x + Spring Cloud Hoxton.SR12 环境。
|
||||
*/
|
||||
@Slf4j
|
||||
//@Component
|
||||
@Component
|
||||
public class LoggingGlobalFilter implements GlobalFilter, Ordered {
|
||||
|
||||
@Override
|
||||
@ -92,8 +94,7 @@ public class LoggingGlobalFilter implements GlobalFilter, Ordered {
|
||||
.map(dataBuffer -> {
|
||||
byte[] content = new byte[dataBuffer.readableByteCount()];
|
||||
dataBuffer.read(content);
|
||||
String bodyStr = new String(content, StandardCharsets.UTF_8);
|
||||
responseBody = bodyStr;
|
||||
responseBody = new String(content, StandardCharsets.UTF_8);
|
||||
return dataBuffer;
|
||||
})
|
||||
.subscribe();
|
||||
|
||||
@ -22,7 +22,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Configuration
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
public class RequestLogGlobalFilter implements GlobalFilter, Ordered {
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
//@Configuration
|
||||
public class ResponseLogGlobalFilter implements GlobalFilter, Ordered {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user