我有一个简单的java项目(maven)。它构建了一个 jar,我们在它上面执行 main 方法。但当我跑步时mvn clean test
在项目中我从 log4j 得到一条日志行说
INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
The log4j2.xml
文件位于src/main/resources/log4j2.xml
.
有什么想法吗?
如果您有servlet-api
如果您将 Jar 放在类路径中,Log4j 会认为您正在 Servlet 容器中运行。具体来说,它会寻找是否存在javax.servlet.ServletContext
。如果您的应用程序没有在 Servlet 容器中运行,那么您确实不需要该 Jar。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)