diff --git a/ruoyi-gateway/src/main/java/org/dromara/gateway/filter/GlobalLogFilter.java b/ruoyi-gateway/src/main/java/org/dromara/gateway/filter/GlobalLogFilter.java index 2c776513..fbfa329a 100644 --- a/ruoyi-gateway/src/main/java/org/dromara/gateway/filter/GlobalLogFilter.java +++ b/ruoyi-gateway/src/main/java/org/dromara/gateway/filter/GlobalLogFilter.java @@ -2,11 +2,11 @@ package org.dromara.gateway.filter; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.json.utils.JsonUtils; import org.dromara.gateway.config.properties.ApiDecryptProperties; import org.dromara.gateway.config.properties.CustomGatewayProperties; import org.dromara.gateway.utils.WebFluxUtils; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; @@ -75,6 +75,9 @@ public class GlobalLogFilter implements GlobalFilter, Ordered { @Override public int getOrder() { + // 日志处理器在负载均衡器之后执行 负载均衡器会导致线程切换 无法获取上下文内容 + // 如需在日志内操作线程上下文 例如获取登录用户数据等 可以打开下方注释代码 + // return ReactiveLoadBalancerClientFilter.LOAD_BALANCER_CLIENT_FILTER_ORDER - 1; return Ordered.LOWEST_PRECEDENCE; }