• 0.48.4

SLF4J and LOG4J Logging

The profile is activated automatically when src/test/resources/log4j.properties file exists in your project. The following two dependencies become available in classpath (in test scope): org.slf4j:slf4j-log4j12 and log4j:log4j.

A good practice is 1) to annotate your methods/classes with @Loggable, 2) activate aspectj profile, and 3) create src/test/resources/log4j.properties file with LOG4J configuration for unit testing.

This page explains the format of log4j.properties: Short introduction to log4j: Ceki Gülcü, March 2002. This is a short example that works:

log4j.rootLogger=INFO, CONSOLE
log4j.appender.CONSOLE.layout.ConversionPattern=[%color{%p}] %t %c: %m%n

In this example we use MulticolorLayout from jcabi-log, which colors log output depending on log priorities.