Hi ,
What u have done is right? The reason is that u must be using the Properties
class and must be passing the obj to the log4j configurator.
U can put ur config file in any folder that u want and if u are using the
Properties class , the following things can be done:
1) set the classpath to that folder which has that properties file. For eg :
let the folder be c:\log4j
set classpath = %classpath%;c:\log4j
2) Assuming the package u are developing is "net.java". in the folder
c:\log4j. So the final directory stucutre is :
c:\log4j\net\java and the file is in this
folder(c:\log4j\net\java\config.txt)
2) Use the following code:
try
{
InputStream isLog4j =
getClass().getResourceAsStream("/net/java/config.txt");
Properties propsLog4j = new Properties();
propsLog4j.load(isLog4j);
isLog4j.close();
//For getting the config file - for log4j
PropertyConfigurator.configure(propsLog4j);
}
catch(Exception e) { e.printStackTrace(); }
Hope this is of some help to u.
This is how u may not require to hard code the absolute path of the config
file.
Bye ,
Jeet.
-----Original Message-----
From: Hansen, Richard [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 11:44 AM
To: LOG4J Users (E-mail)
Subject: log4j.properties file location bug?
I don't know if this is a exactly bug. But is an issue and should at least
be added to the FAQ I think. To get log4j to automatically load a properties
file I need to explicitly add the log4j jars to the classpath. Next, I must
put the properties file in the same directory as the log4j jar files. Last,
I need to add the directory with the jars and property file into the
classpath. Someone please correct me if I am wrong, but that is the only way
I could seem to get working.
This means that you cannot put log4j jars in the "jre/lib/ext" directory for
auto loading by the JVM. Even if you add the "jre/lib/ext" directory to the
classpath and put the property file there log4j does not find it. Does the
XML configuration work the same way?
Rick Hansen
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]