I am trying to implement logging interceptor for all my classes that are invoked when user request is processed by the server.
The framework we have in place is as follows:
Action -> Service -> DAO -> Adapter -> 3rd Party API invocation.
When using struts interceptors, I implemented the logging. However, it only intercepts the action classes and prints the entry/exit of action classes. I want to extend this to ensure entry/exit of all methods are printed so that it helps me in debugging the code on production. However, it seems by default struts doesn't offer this.
Has anyone implemented such requirement ? If yes please share your learning.
Success is not doing extraordinary things but doing ordinary things extraordinarily well.
I agree with you on Spring part. It allows method level interception(before-after).
If you want method level interception for various methods, you might have to leverage regular expressions withing AOP.
I haven't implemented these though.
However, what you're looking for; i have not seen that in Struts.
Saurabh Agrawal wrote:I don't think that is a java limitation. Frameworks like sprint allow using point cut strategy to intercept each class and it's corresponding methods to print log messages.
I was referring to built-in functionality. For certain, if you want jump through some hoops with AOP, you can cobble something together. You can use Spring with Struts, but I don't know if that gets you any closer to your goal.
I just start each "interesting" method with a log statement and use log levels to throttle the amount of information that is logged.