From 20a294c6ad3dfa630fc6c85ac540bc6d6706ba67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 14 Aug 2024 09:37:00 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97=E5=A4=84=E7=90=86=E5=99=A8=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dromara/gateway/filter/GlobalLogFilter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; }