log4j拾取错误的属性文件 [英] log4j picking up wrong properties file

查看:172
本文介绍了log4j拾取错误的属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的类路径中有2个log4j.properties文件。我需要两个 - 其中一个是我所使用的库,另一个是我的代码使用的库。当我运行我的jar文件,它能够读取库使用的属性,但它不是正在读取我自己的属性文件。如何让它读取我的log4j,而不必在所有的源文件中使用PropertytConfigurator?

There are 2 log4j.properties files in my classpath. I need both of them - One of them is required for a library that I am using and another is the one used by my code. When I run my jar file, it is able to read the properties used by the library, but it is not reading my own properties file. How can I make it read my log4j without having to use PropertytConfigurator in all my source files? Is there any way I can configure it so that it used both the properties files together?

推荐答案

要回答你的第一个问题,你

To answer your first question, you can point it to your own file by giving it a unique name and adding the following system property when you launch your application.

-Dlog4j.configuration=path_to_my_properties_file

我不认为可以使用2个不同的文件,程序化。

I don't think it is possible to use 2 different files without doing anything programatically.

这篇关于log4j拾取错误的属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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