【发布时间】:2021-08-25 18:43:35
【问题描述】:
标题说明了一切。如何在我的 Open-liberty 项目中设置 log4j2 配置?我在资源文件夹中添加了我的 log4j2.xml 文件,并在我的 pom.xml 中使用了以下依赖项:
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
这是我的 server.xml:
<server description="Intake Server">
<featureManager>
<feature>servlet-4.0</feature>
<feature>mpConfig-1.4</feature>
<feature>cdi-2.0</feature>
</featureManager>
<variable name="default.http.port" defaultValue="9080"/>
<variable name="default.https.port" defaultValue="9443"/>
<variable name="app.context.root" defaultValue="message"/>
<httpEndpoint httpPort="${default.http.port}"
httpsPort="${default.https.port}" id="defaultHttpEndpoint" host="*" />
<library id="log4jConfig">
<folder dir="/var/log/intake" scanInterval="5s" />
</library>
<webApplication id="intake" location="intake.war" contextRoot="${app.context.root}">
<classloader commonLibraryRef="log4jConfig"/>
</webApplication>
</server>
【问题讨论】:
-
你的库不是 log4j2 而是 log4j 1.2.17。尝试最后一个 log4j2 版本:2.17.0
标签: java log4j log4j2 open-liberty