Jayesh A Lalwani wrote:I might not be understand your post. Why do you need AOP for logging? Can't you just use JDK logging?
The requirement is that every application should have the ability to log whatever it wants without the Developer having to worry about AOP.
I created a logging interface that pretty much just has a writeMessage(String, String). The policy will be any app that wants to log will need to implement this interface, thus implementing the dummy
writeMessage method
Annotations
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Mark Spritzler wrote:Sam, I would say that if you have to log elsewhere, in the middle of your method, then your method has low cohesion and is doing more than one thing. So for me the logging in the middle of a method is a huge code smell.
Mark Spritzler wrote:
Also, with AOP before and after, I can get full context of what is being called so I can put everything I need of information logged in my AOP logger. Done right, Using AOP with creating your own @Logging() annotation is the easiest most elegant solution you can find for Logging. I do it all the time and it has made my code that much better.
Mark
Mark Spritzler wrote:
"concerned about annotation overhead and the responsibility of the developer to create annotations" (Removed rude comment I made, I should call someone an idiot. I already know there are no idiots, just that we aren't seeing your Architect's expertise here.)
Mark
Mark Spritzler wrote:
I already know there are no idiots
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
don't think its a bad idea - though I personally would prefer using XML to do the configuration. Simple reason is that if any new method is added - no one accidentally forgets to add the @Logging annotation. I like to leave as few possibility for people accidentally forgetting to do something!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |