(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");