我正在尝试使用 Log4j 运行一个 groovy 脚本。脚本运行良好,但 log4j 未初始化。我已将 log4j.properties 放在 src/main/resources 中,并且还将资源包含在 pom.xml 的构建部分中。下面是 pom.xml 的一部分
<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>
我使用以下命令来执行脚本:
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.