How do I configure log4j per deployed application in Glassfish 3?
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.
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.
链接地址: http://www.djcxy.com/p/52068.html上一篇: 在模板类中隐藏成员函数