javaslf4jvelocityslf4j-api

Velocity 2.0 Migration LogChute Replacement


I am trying to migrate to Velocity 2.0 from 1.7. After reading some of the documentation, I see that Velocity now has moved on to the SLF4j API for its logging. Now I am not a an expert on how to use SLF4j, but since it has some documentation, I am sure I will figure it out.

public class VelocityLogger implements LogChute

I had a class which implemented the LogChute interface. After reading a bit about the new logging framework, would:

SimpleLogger

be an apt replacement? I just want to know if my analysis at the start is correct, before I mess it up going down the wrong path.


Solution

  • There is no replacement for LogChute, the slf4j logging framework works statically. You only need to provide one (and only one) slf4j implementation (aka backend) package along with the slf4j-api one in your classpath.

    And yes, it can be the SimpleLogger or logback, as long as some bridge towards another logging framework or some other implementation, there are a few out there.

    I wrote one specifically to redirect logs towards the logger of the J2EE container: webapp-slf4j-logger. You'll find an example of integration in the velocity-tools-example-showcase webapp.