You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Eric Pieters <er...@gmail.com> on 2005/06/17 02:43:20 UTC

log4 configuration file inside a jar

Hi,

I would like to bundle a configuration file inside a jar.

Inside my app I use the following;

DOMConfigurator.configure("myApp.xml");

The manifest file of the jar in which myApp.xml is bundled 
contains the following:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.4
Created-By: 1.4.2_07-b05 (Sun Microsystems Inc.)
Class-Path: conf/

and inside the jar myApp.xml resides in the conf directory.
So you get;

org/myApp/1.class
org.myApp/2.class
conf/myApp.xml

>From reading info on JAR Manifest structure etc. I assume the above 
should work. But it doesn't. I throws a FileNotFoundException.

Has somebody already successfully bundled the config file inside 
a jar and point me into the correct direction?

Thanks.

Eric.


Re: log4 configuration file inside a jar

Posted by Curt Arnold <ca...@apache.org>.

On Jun 16, 2005, at 7:43 PM, Eric Pieters wrote:

> Hi,
>
> I would like to bundle a configuration file inside a jar.

Sounds like a question for log4j-user@logging.apache.org not log4cxx- 
user.

DOMConfigurator.configure(String) gives no indication that its  
parameter is treated as anything other than plain filename.  So  
expecting it to be used in a search within a jar file is unwarranted.

I think what you you would likely end up needing to do is to obtain  
an URL for the resource using org.MyApp.MyClass.class.getResource("/ 
conf/MyApp.xml") and then calling DOMConfigurator(URL).