diff --git a/src/main/java/neatlogic/framework/asynchronization/threadlocal/RequestContext.java b/src/main/java/neatlogic/framework/asynchronization/threadlocal/RequestContext.java
index 413c43e3b78892d9296820d122d81db2a15c6690..d3aeffcd61917ea021734fd2e641b49324f2b14b 100644
--- a/src/main/java/neatlogic/framework/asynchronization/threadlocal/RequestContext.java
+++ b/src/main/java/neatlogic/framework/asynchronization/threadlocal/RequestContext.java
@@ -74,17 +74,7 @@ public class RequestContext implements Serializable {
public void setParam(String param) {
this.param = param;
- String tempUrl = StringUtils.EMPTY;
- if (StringUtils.isNotBlank(this.url)) {
- tempUrl = this.url;
- }
- if (StringUtils.isNotBlank(this.remoteAddr)) {
- tempUrl += "(" + this.remoteAddr + ")";
- }
- if (StringUtils.isNotBlank(this.param)) {
- tempUrl += "(param=" + this.param + ")";
- }
- MDC.put("url", tempUrl);
+ MDC.put("param", this.param);
}
public HttpServletRequest getRequest() {
@@ -180,11 +170,11 @@ public class RequestContext implements Serializable {
if (StringUtils.isNotBlank(remoteAddr)) {
tempUrl += "(" + remoteAddr + ")";
}
+ MDC.put("url", tempUrl);
String param = _requestContext.getParam();
if (StringUtils.isNotBlank(param)) {
- tempUrl += "(param=" + param + ")";
+ MDC.put("param", param);
}
- MDC.put("url", tempUrl);
}
instance.set(context);
return context;
diff --git a/src/main/java/neatlogic/framework/logback/converter/RequestParamConverter.java b/src/main/java/neatlogic/framework/logback/converter/RequestParamConverter.java
new file mode 100644
index 0000000000000000000000000000000000000000..5cbccf88a5a3e4c46f4a0f435ba4dceffca85c33
--- /dev/null
+++ b/src/main/java/neatlogic/framework/logback/converter/RequestParamConverter.java
@@ -0,0 +1,36 @@
+/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .*/
+
+package neatlogic.framework.logback.converter;
+
+import ch.qos.logback.classic.pattern.ClassicConverter;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+import java.util.Map;
+
+public class RequestParamConverter extends ClassicConverter implements Serializable {
+
+ @Override
+ public String convert(ILoggingEvent event) {
+ Map map = event.getMDCPropertyMap();
+ String param = map.get("param");
+ if (StringUtils.isNotBlank(param)) {
+ return param;
+ }
+ return StringUtils.EMPTY;
+ }
+}
diff --git a/src/main/java/neatlogic/module/framework/login/handler/LoginController.java b/src/main/java/neatlogic/module/framework/login/handler/LoginController.java
index 66606d2d5bcb0eb372928e1a0d75d8ca75a47d25..36f3eeb020b5f63cddded255982f91894f245918 100644
--- a/src/main/java/neatlogic/module/framework/login/handler/LoginController.java
+++ b/src/main/java/neatlogic/module/framework/login/handler/LoginController.java
@@ -17,6 +17,7 @@ package neatlogic.module.framework.login.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
import neatlogic.framework.asynchronization.threadlocal.RequestContext;
import neatlogic.framework.asynchronization.threadlocal.TenantContext;
import neatlogic.framework.asynchronization.threadlocal.UserContext;
@@ -98,7 +99,7 @@ public class LoginController {
JSONObject jsonObj = JSON.parseObject(json);
TenantContext tenantContext = TenantContext.init();
//初始化request上下文
- RequestContext.init(request, request.getRequestURI(), response).setParam(json);
+ RequestContext.init(request, request.getRequestURI(), response).setParam(JSON.toJSONString(jsonObj, SerializerFeature.PrettyFormat));
JSONObject resultJson = new JSONObject();
try {
String userId = jsonObj.getString("userid");
diff --git a/src/main/java/neatlogic/module/framework/restful/dispatch/handler/AnonymousApiDispatcher.java b/src/main/java/neatlogic/module/framework/restful/dispatch/handler/AnonymousApiDispatcher.java
index 04f07b5b2df24e2c3f6034656bfdaaecd025ca42..19ab5bd4ab67faef1cc26ff1483e1c81180ba9b7 100644
--- a/src/main/java/neatlogic/module/framework/restful/dispatch/handler/AnonymousApiDispatcher.java
+++ b/src/main/java/neatlogic/module/framework/restful/dispatch/handler/AnonymousApiDispatcher.java
@@ -96,7 +96,7 @@ public class AnonymousApiDispatcher {
}
InputFromContext.init(inputFrom);
ApiVo interfaceVo = PrivateApiComponentFactory.getApiByToken(token);
- RequestContext.init(request, token, response).setParam(paramObj.toJSONString());
+ RequestContext.init(request, token, response).setParam(JSON.toJSONString(paramObj, SerializerFeature.PrettyFormat));
ApiVo dbApiVo = apiMapper.getApiByToken(token);
if (interfaceVo == null) {
if (dbApiVo != null) {
diff --git a/src/main/java/neatlogic/module/framework/restful/dispatch/handler/ApiDispatcher.java b/src/main/java/neatlogic/module/framework/restful/dispatch/handler/ApiDispatcher.java
index 2aa2f8793aaf77987b8912c0952d3201fc2c6c41..b858c96a207b3bf5df889ebce4cf75620c4a65a9 100644
--- a/src/main/java/neatlogic/module/framework/restful/dispatch/handler/ApiDispatcher.java
+++ b/src/main/java/neatlogic/module/framework/restful/dispatch/handler/ApiDispatcher.java
@@ -112,11 +112,11 @@ public class ApiDispatcher {
inputFrom = InputFrom.UNKNOWN;
}
InputFromContext.init(inputFrom);
- RequestContext.get().setParam(paramObj.toJSONString());
- ApiVo interfaceVo = PrivateApiComponentFactory.getApiByToken(token);
if (paramObj == null) {
paramObj = new JSONObject();
}
+ RequestContext.get().setParam(JSON.toJSONString(paramObj, SerializerFeature.PrettyFormat));
+ ApiVo interfaceVo = PrivateApiComponentFactory.getApiByToken(token);
ApiVo dbApiVo = apiMapper.getApiByToken(token);
if (interfaceVo == null) {
if (dbApiVo != null) {
diff --git a/src/main/java/neatlogic/module/framework/restful/dispatch/handler/PublicApiDispatcher.java b/src/main/java/neatlogic/module/framework/restful/dispatch/handler/PublicApiDispatcher.java
index f940b3c0d644b4cbff106b18918935c73b76019f..eec05d041ed6d200763e69a36f688ebe9d56c443 100644
--- a/src/main/java/neatlogic/module/framework/restful/dispatch/handler/PublicApiDispatcher.java
+++ b/src/main/java/neatlogic/module/framework/restful/dispatch/handler/PublicApiDispatcher.java
@@ -15,8 +15,10 @@ along with this program. If not, see .*/
package neatlogic.module.framework.restful.dispatch.handler;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONReader;
+import com.alibaba.fastjson.serializer.SerializerFeature;
import neatlogic.framework.asynchronization.threadlocal.InputFromContext;
import neatlogic.framework.asynchronization.threadlocal.RequestContext;
import neatlogic.framework.asynchronization.threadlocal.TenantContext;
@@ -105,7 +107,7 @@ public class PublicApiDispatcher {
inputFrom = InputFrom.UNKNOWN;
}
InputFromContext.init(inputFrom);
- RequestContext.init(request, token, response).setParam(paramObj.toJSONString());
+ RequestContext.init(request, token, response).setParam(JSON.toJSONString(paramObj, SerializerFeature.PrettyFormat));
//初始化时区
Cookie[] cookies = request.getCookies();
String timezone = TimeUtil.ZONE_TIME;