Creating a new version of my RESTful service architecture using JEE 7, deploying to a Wildfly 9 instance, I was wondering if there is a clever way to create a log system, can you suggest some patterns? Thanks a lot.
I am using a simple producer with SLF4J interface for a JavaEE 7 JAX-RS project.
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoggerProducer
{
@Produces
public Logger getLogger(final InjectionPoint ip)
{
return LoggerFactory.getLogger(ip.getMember().getDeclaringClass());
}
}
The usage is quite convenient by using injection.
@Inject
private Logger logger;
And the implementation can be changed easily without affecting any business classes. As the implementation slf4j-simple is sufficient for me, but if you need more advanced stuff, I would have a look at logback as already suggested or log4j 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With