0

我已经配置了 gradle-tomcat-plugin,但是当我运行任务时,找不到文件夹中tomcatRun的 log4j.xml 配置文件:src/main/resources

log4j:WARN No appenders could be found for logger
...

在记录器的线程中,我可以使用

Thread.currentThread().getContextClassLoader().getResource("log4j.xml"); // project_root/build/resources/main/log4j.xml

这在理论上是 log4j 加载文件的方式。

如果我在 Tomcat 安装中部署战争,我没有这个问题。

运行任务的完整日志:

12:03:16: Executing task 'tomcatRun'...

> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE

> Task :tomcatRun
Started Tomcat Server
The Server is running at http://localhost:8080/project_context

(this comes from a System.out.println() before trying to use the logger)
File : /C:/Users/MyUsername/IdeaProjects/project_name/build/resources/main/log4j.xml

log4j:WARN No appenders could be found for logger (Classname).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
4

0 回答 0