开发者

Using log4j for different applications

开发者 https://www.devze.com 2023-04-06 00:15 出处:网络
I have a problem with log4j loggin and I hope you can help me on this. This is the scenario: I have 3 different applications (in other words 3 .jar) A, B and C. A is always running and from time to t

I have a problem with log4j loggin and I hope you can help me on this.

This is the scenario: I have 3 different applications (in other words 3 .jar) A, B and C. A is always running and from time to time calls B and C to execute them. Each of them have its own log4j.properties (with the path duly included in the MANIFEST) but Log4j only takes the properties of the main app A into consideration, ignoring the rest. I need to know if I can force Log4j to use for each app i开发者_Go百科ts own properties. I have seen something related using DOMConfigurator, but if I'm not wrong this only works with xml files and I'm using properties.

Thanks in advance


There are several Configurators, one of which is the PropertyConfigurator.


I need to know if I can force Log4j to use for each app its own properties.

Yes, you can. When you launch the applications B and C, define this system variable at their command line:

-Dlog4j.configuration=B.properties

where B.properties is the file name of log4j properties file in B's classpath. Likewise for application C.

Edit: found this: Change location of log4j.properties

0

精彩评论

暂无评论...
验证码 换一张
取 消