Websphere Liberty:如何指定log4j2配置位置? [英] Websphere Liberty: How to specify log4j2 configuration location?

查看:331
本文介绍了Websphere Liberty:如何指定log4j2配置位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图告诉Websphere Liberty我的log4j2.xml文件在哪里,但是它不起作用.

I'm trying to tell Websphere Liberty where is located my log4j2.xmlfile, but it isn't working.

在我的文件jvm.options中,我配置:

In my file jvm.options I configure:

-Dlog4j.configurationFile=file:///${server.config.dir}/log4j2.xml

,但看起来Liberty无法理解jvm.options文件中的变量$ {server.config.dir}.该文件与server.xml文件位于同一目录中.

but it looks like Liberty does not understand the variable ${server.config.dir} in the jvm.options file. The file is in the same directory of the server.xml file.

如何为Liberty指定log4j2.xml位置?

How would I specify the log4j2.xml location for Liberty?

推荐答案

我认为应该可以通过在server.xml中创建一个Library条目来实现,例如:

I think it should be possible by creating a Library entry in your server.xml such as:

<library id="log4jLib">
   <folder dir="/opt/log4j2/config"/>
</library>

其中指定的目录包含log4j2属性或xml文件.

where the directory specified contains the log4j2 properties or xml file.

然后为您的应用程序指定一个类加载器,如下所示:

Then specify a classloader for your application like this:

<application id="test" name="test" type="ear" location="test.ear">
  <classloader commonLibraryRef="log4jLib" />
</application>

这篇关于Websphere Liberty:如何指定log4j2配置位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆