Suppress logging for Velocity

If you don’t want Velocity to log anything, you can change its default logging behavior. All you have to do is to implement an interface and set a property before you call Velocity.init().

Depending on the version of Velocity you’re using you’ll have to implement either LogSystem or LogChute.

Continue reading →

Logging with AspectJ

Again, I would like to endorse the usage of aspect oriented programming because it may ease development significantly. That’s almost always the case with crosscutting concerns like logging and in this post we’ll develop a solution with AspectJ. So, adding logging to your application is as easy as this:

  • implement this AbstractLoggingAspect and define the methods you’d like to monitor
  • declare advice before, after or around the logging pointcut and println your logging to stdout.

Once you’re finished with this you’ve got logging in your application without touching the original code. We’ll have a look at the details in the next sections.

If you’d like to check out the code that accompanies this post you can download the Eclipse project as tar.gz or zip; make sure to install the AspectJ Development Tools. You can browse the code online here.

Continue reading →