Thanks very much - those libraries work perfectly. I have one minor problem remaining, I would like the log message that is printed on entering a method to look like this:
Code:
<Entering method: [ VoicePolicyValidator.supports ] param-0 [ true ]>
But currently it looks like this:
Code:
<Entering method: [ VoicePolicyValidator.execution(supports) ] param-0 [ true ]>
I could remove the extraneous "execution()" myself, but I expect there's probably some way to get just the method name of the target of the ProceedingJoinPoint. I've appended the code that builds this String in case you want to have a look.
Thanks Again,
DM
Code:
public class MethodLogger {
private static final Logger LOG = Logger.getLogger(MethodLogger.class);
public Object log(ProceedingJoinPoint call) throws Throwable {
int paramIndex = 0;
StringBuilder sb = new StringBuilder();
sb.append("Entering method: ");
//
// Add the class name, then '.', then the method name
//
String methodName = "[ " + call.getTarget().getClass().getSimpleName() + '.'
+ call.toShortString() + " ]";
sb.append(methodName);
//
// Append the method arguments
//
for (Object arg : call.getArgs()) {
sb.append(" param-" + paramIndex++);
if (arg == null) {
sb.append(" [ NULL ]");
} else {
sb.append(" [ " + arg + " ]");
}
}
LOG.trace(sb.toString());
return call.proceed();
}
}