Users that want to use the Apache log4j 1.x package and let Guice injects automagically org.apache.log4j.Logger instances, have to add the following dependency in the pom.xml:
<dependency> <groupId>org.apache.onami.logging</groupId> <artifactId>org.apache.onami.logging.log4j2</artifactId> <version>3.4.1-SNAPSHOT</version> <scope>compile</scope> </dependency>
then, when creating the com.google.inject.Injector, add the org.apache.onami.logging.log4j2.Log4jLoggingModule module; please take note that users have to specify the classes com.google.inject.matcher.Matcher for whom the logging injection has to be applied:
import com.google.inject.Guice; import com.google.inject.Injector; import org.apache.onami.logging.log4j2.Log4j2LoggingModule; import com.google.inject.matcher.Matchers; ... Injector injector = Guice.createInjector( new Log4j2LoggingModule( Matchers.any() ), ... );
and the magic happens :)