diff --git a/marketplace-service/src/main/java/com/axonivy/market/logging/LoggableAspect.java b/marketplace-service/src/main/java/com/axonivy/market/logging/LoggableAspect.java index 059a1998..48a7712b 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/logging/LoggableAspect.java +++ b/marketplace-service/src/main/java/com/axonivy/market/logging/LoggableAspect.java @@ -16,8 +16,11 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; import java.util.Map; import static com.axonivy.market.util.FileUtils.createFile; @@ -38,8 +41,9 @@ public void logMethodCall(JoinPoint joinPoint) throws MissingHeaderException { ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (attributes != null) { + Method method = signature.getMethod(); HttpServletRequest request = attributes.getRequest(); - Map headersMap = extractHeaders(request, signature, joinPoint); + Map headersMap = extractHeaders(request, method, joinPoint); saveLogToDailyFile(headersMap); // block execution if request isn't from Market or Ivy Designer @@ -49,13 +53,16 @@ public void logMethodCall(JoinPoint joinPoint) throws MissingHeaderException { } } - private Map extractHeaders(HttpServletRequest request, MethodSignature signature, + private Map extractHeaders(HttpServletRequest request, Method method, JoinPoint joinPoint) { return Map.of( - LoggingConstants.METHOD, escapeXml(String.valueOf(signature.getMethod())), + LoggingConstants.METHOD, escapeXml(String.valueOf(method)), LoggingConstants.TIMESTAMP, escapeXml(getCurrentTimestamp()), CommonConstants.USER_AGENT, escapeXml(request.getHeader(CommonConstants.USER_AGENT)), - LoggingConstants.ARGUMENTS, escapeXml(getArgumentsString(signature.getParameterNames(), joinPoint.getArgs())), + LoggingConstants.ARGUMENTS, + escapeXml(getArgumentsString( + Arrays.stream(method.getParameters()).map(Parameter::getName).toArray(String[]::new), + joinPoint.getArgs())), CommonConstants.REQUESTED_BY, escapeXml(request.getHeader(CommonConstants.REQUESTED_BY)) ); }