maven-plugin-log4j is not a maven2 plugin. This is Log4j Appender for Maven 2 Plugin.
It simplify the used of libraries that are using log4j inside Maven 2 Plugin by redirecting log4j log and debug massages to maven log.
Add dependency
<dependencies>
....
<dependency>
<groupId>com.pyx4j</groupId>
<artifactId>maven-plugin-log4j</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>Initializing log redirector in Mogo.
public class YourMojo extends AbstractMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
MavenLogAppender.startPluginLog(this);
try {
...
} finally {
MavenLogAppender.endPluginLog(this);
}
}
}
Nothing needs to be done to initialize log4j. log4j.xml alredy in maven-plugin-log4j.jar. This is how it looks like.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j//DTD//EN" "http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/log4j.dtd">
<log4j:configuration>
<appender name="MavenLogAppender" class="com.pyx4j.log4j.MavenLogAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%m" />
</layout>
</appender>
<root>
<level value="debug" />
<appender-ref ref="MavenLogAppender" />
</root>
</log4j:configuration>