如何为单个Maven插件执行设置log4j级别?

时间:2013-01-02 17:54:23

标签: maven log4j maven-plugin

我正在使用Maven -assembly-plugin并获得ton&大量的INFO消息列出了所有被忽略的重复条目。有没有办法将log4j级别设置为“WARN”以执行此单个插件?

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <outputDirectory>${basedir}/../package/lib</outputDirectory>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>

    </executions>
</plugin>

e.g。请注意以下步骤中log4j输出的示例中的重复:

...
[INFO] META-INF/notice.txt already added, skipping
[INFO] META-INF/spring.handlers already added, skipping
[INFO] META-INF/spring.schemas already added, skipping
[INFO] META-INF/spring.tooling already added, skipping
[INFO] META-INF/INDEX.LIST already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/license.txt already added, skipping
[INFO] META-INF/notice.txt already added, skipping
[INFO] overview.html already added, skipping
[INFO] META-INF/INDEX.LIST already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/license.txt already added, skipping
[INFO] META-INF/notice.txt already added, skipping
[INFO] META-INF/spring.handlers already added, skipping
[INFO] META-INF/spring.schemas already added, skipping
[INFO] META-INF/spring.tooling already added, skipping 
...

在我的情况下,我有大约3,000条这些[INFO]消息。这会使Maven构建输出膨胀,并且更难以看到真正的错误。

谢谢,

标记

2 个答案:

答案 0 :(得分:0)

如果你使用Maven 2.x似乎不可能,请参阅this

您可以添加参数'-q'或'--quiet'以使Maven仅显示错误,但它是一个全局选项。

答案 1 :(得分:0)

我不知道使用log4j的答案,但您可以使用下一版本的程序集插件来解决您的问题

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
</plugin>