开发者

How do I configure log4j per deployed application in Glassfish 3?

开发者 https://www.devze.com 2023-02-28 01:15 出处:网络
I\'m trying to use log4j to handle the logs for a web-service which is running under Glassfish 3. Most of the guides I\'ve seen using log4j with Glassfish want me to mess around with Glassfish global

I'm trying to use log4j to handle the logs for a web-service which is running under Glassfish 3. Most of the guides I've seen using log4j with Glassfish want me to mess around with Glassfish global settings, which I want to avoid as there will be more than one application deployed per instance of Glassfish.

开发者_如何学Python

Is there any way for me to have Glassfish execute a piece of code when my web service is deployed which will allow me to call DOMConfigurator and set up log4j using my XML file?

Thanks for any help!

EDIT: The answer is to place the log4j.xml file in WEB-INF/classes. In our case, it looks as if log4j remains un-configured, but logging does still actually work as expected.


Yes. All you need to do is deploy the log4j configuration with the component you're deploying; log4j will use the locally-scoped configuration as long as it's not being referenced in a parent classloader.

Glassfish' global settings won't factor in at all in that case.

0

精彩评论

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