1
我試圖運行Log4j的groovy腳本。 腳本運行正常,但log4j未初始化。我已經將log4j.properties放置在src/main/resources中,並且還將資源包含在pom.xml的build部分中。下面是運行maven時未初始化log4j執行
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-2.0</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>2.1.9</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<configuration>
<providerSelection>2.0</providerSelection>
<source>
${pom.basedir}/src/main/groovy/Hello.groovy
</source>
</configuration>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
<goal>generateStubs</goal>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
我用下面的命令來執行腳本的pom.xml的一部分:在腳本執行結束
mvn org.codehaus.gmaven:gmaven-plugin:1.5:execute
我得到以下警告:
log4j:WARN No appenders could be found for logger (...).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.