🎨 参数打印屏蔽 password 字段

This commit is contained in:
ronger 2021-04-29 10:16:30 +08:00
parent c8df03ccd1
commit 82cdf1d4d1

View File

@ -61,12 +61,18 @@ public class WebLogAspect {
+ joinPoint.getSignature().getDeclaringTypeName() + joinPoint.getSignature().getDeclaringTypeName()
+ "." + "."
+ joinPoint.getSignature().getName()); + joinPoint.getSignature().getName());
logger.info("ARGS : " + Arrays.toString(joinPoint.getArgs())); logger.info("ARGS : " + Arrays.toString(joinPoint.getArgs())
.replaceAll("(?<=password).*?(?=(nickname|$))", "=****, ")
.replaceAll("(?<=password).*?(?=(\\)|$))", "=****)]")
.replaceAll("(?<=password).*?(?=(code|$))", "=****, "));
// 获取所有参数方法一 // 获取所有参数方法一
Enumeration<String> enu = request.getParameterNames(); Enumeration<String> enu = request.getParameterNames();
while (enu.hasMoreElements()) { while (enu.hasMoreElements()) {
String paraName = (String) enu.nextElement(); String paraName = enu.nextElement();
if ("password".equals(paraName)) {
continue;
}
logger.info(paraName + ": " + request.getParameter(paraName)); logger.info(paraName + ": " + request.getParameter(paraName));
} }
} }