I have a spring BlazeDS integration application. I would like to log all the request.
I planned to use Filter. In my filter when I check the request parameter. It does not contain anything related to the client request. If I change the order of my filter(I have spring Security), then it prints some thing related to spring security.
I am unable to log the user request.
Any help is appreciated.
I have done the same functionality by using AOP (AspectJ) to inject a logger statement into communication endpoint methods. -- May this is an alternative approach for you too.
/** Logger advice and pointcuts for flex remoting stuff based on aspect J*/
public aspect AspectJInvocationLoggerAspect {
/** The name of the used logger. */
public final static String LOGGER_NAME = "myPackage.FLEX_INVOCATION_LOGGER";
/** Logger used to log messages. */
private static final Logger LOGGER = Logger.getLogger(LOGGER_NAME);
AspectJInvocationLoggerAspect() {
}
/**
* Pointcut for all flex remoting methods.
*
* Flex remoting methods are determined by two constraints:
* <ul>
* <li>they are public</li>
* <li>the are located in a class of name Remoting* within (implement an interface)
* {@link com.example.remote} package</li>
* <li>they are located within a class with an {@link RemotingDestination} annotation</li>
* </ul>
*/
pointcut remotingServiceFunction()
: (execution(public * com.example.remote.*.*Remote*.*(..)))
&& (within(@RemotingDestination *));
before() : remotingServiceFunction() {
if (LOGGER.isDebugEnabled()) {
Signature sig = thisJoinPointStaticPart.getSignature();
Object[] args = thisJoinPoint.getArgs();
String location = sig.getDeclaringTypeName() + '.' + sig.getName() + ", args=" + Arrays.toString(args);
LOGGER.debug(location + " - begin");
}
}
/** Log flex invocation result at TRACE level. */
after() returning (Object result): remotingServiceFunction() {
if (LOGGER.isTraceEnabled()) {
Signature sig = thisJoinPointStaticPart.getSignature();
String location = sig.getDeclaringTypeName() + '.' + sig.getName();
LOGGER.trace(location + " - end = " + result);
}
}
}