(originally posted here on 24 Jul 2005)
Ever wonder how to ship a jar with a log4j.xml inside it? In the jar’s main class, use
static // loads before anything else can
{
/*
* If log4j.configuration system property isn't set,
* then assume I'm inside a jar and configure
* log4j using the config file that shipped in the jar.
*/
if (System.getProperty("log4j.configuration") == null)
{
URL url = ClassLoader.getSystemResource("log4j.xml");
DOMConfigurator.configure(url);
}
}
I won't accept such sort of family though it is quite comfortable. I prefer the family with mom which is not rich but ample in my heart
Posted by: Coach Outlet | February 17, 2011 at 21:09