|
@@ -3,6 +3,7 @@ package com.citu.gateway.filter.logging;
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.alibaba.nacos.common.utils.JacksonUtils;
|
|
import com.citu.framework.common.util.json.JsonUtils;
|
|
import com.citu.framework.common.util.json.JsonUtils;
|
|
import com.citu.gateway.util.SecurityFrameworkUtils;
|
|
import com.citu.gateway.util.SecurityFrameworkUtils;
|
|
import com.citu.gateway.util.WebFrameworkUtils;
|
|
import com.citu.gateway.util.WebFrameworkUtils;
|
|
@@ -81,12 +82,19 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
|
values.put("schema", gatewayLog.getSchema());
|
|
values.put("schema", gatewayLog.getSchema());
|
|
values.put("requestUrl", gatewayLog.getRequestUrl());
|
|
values.put("requestUrl", gatewayLog.getRequestUrl());
|
|
values.put("queryParams", gatewayLog.getQueryParams().toSingleValueMap());
|
|
values.put("queryParams", gatewayLog.getQueryParams().toSingleValueMap());
|
|
|
|
+
|
|
values.put("requestBody", JsonUtils.isJson(gatewayLog.getRequestBody()) ? // 保证 body 的展示好看
|
|
values.put("requestBody", JsonUtils.isJson(gatewayLog.getRequestBody()) ? // 保证 body 的展示好看
|
|
- JSONUtil.parse(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
|
|
|
|
|
|
+ JacksonUtils.toObj(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
|
|
|
|
+// JSONUtil.parse(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
|
|
|
|
+
|
|
|
|
+
|
|
values.put("requestHeaders", JsonUtils.toJsonString(gatewayLog.getRequestHeaders().toSingleValueMap()));
|
|
values.put("requestHeaders", JsonUtils.toJsonString(gatewayLog.getRequestHeaders().toSingleValueMap()));
|
|
values.put("userIp", gatewayLog.getUserIp());
|
|
values.put("userIp", gatewayLog.getUserIp());
|
|
values.put("responseBody", JsonUtils.isJson(gatewayLog.getResponseBody()) ? // 保证 body 的展示好看
|
|
values.put("responseBody", JsonUtils.isJson(gatewayLog.getResponseBody()) ? // 保证 body 的展示好看
|
|
- JSONUtil.parse(gatewayLog.getResponseBody()) : gatewayLog.getResponseBody());
|
|
|
|
|
|
+ JacksonUtils.toObj(gatewayLog.getResponseBody()) : gatewayLog.getRequestBody());
|
|
|
|
+// JSONUtil.parse(gatewayLog.getResponseBody()) : gatewayLog.getResponseBody());
|
|
|
|
+
|
|
|
|
+
|
|
values.put("responseHeaders", gatewayLog.getResponseHeaders() != null ?
|
|
values.put("responseHeaders", gatewayLog.getResponseHeaders() != null ?
|
|
JsonUtils.toJsonString(gatewayLog.getResponseHeaders().toSingleValueMap()) : null);
|
|
JsonUtils.toJsonString(gatewayLog.getResponseHeaders().toSingleValueMap()) : null);
|
|
values.put("httpStatus", gatewayLog.getHttpStatus());
|
|
values.put("httpStatus", gatewayLog.getHttpStatus());
|