|
@@ -3,9 +3,11 @@ package com.fdkankan.gateway.filter;
|
|
|
import cn.hutool.core.net.URLDecoder;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.fdkankan.common.constant.LoginType;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
import com.fdkankan.gateway.log.GatewayLog;
|
|
|
import com.fdkankan.gateway.util.WebUtil;
|
|
|
+import com.yomahub.tlog.context.TLogContext;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.reactivestreams.Publisher;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -80,6 +82,8 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
|
|
gatewayLog.setTargetServer(route.getId());
|
|
|
gatewayLog.setRequestTime(new Date());
|
|
|
gatewayLog.setIp(ipAddress);
|
|
|
+ gatewayLog.setTraceId(TLogContext.getTraceId());
|
|
|
+
|
|
|
|
|
|
MediaType mediaType = request.getHeaders().getContentType();
|
|
|
|
|
@@ -160,7 +164,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
|
|
* @param gatewayLog 网关日志
|
|
|
*/
|
|
|
private void writeAccessLog(GatewayLog gatewayLog) {
|
|
|
- log.info(gatewayLog.toString());
|
|
|
+ log.info(JSON.toJSONString(gatewayLog));
|
|
|
//日志写入mongodb
|
|
|
mongoTemplate.insert(gatewayLog, "gatewayLog");
|
|
|
}
|