You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Mark T. Buscher" <mb...@objectframe.com> on 2001/04/25 06:19:19 UTC

Question - PropertyConfigrator

Hello.  First things first... great work with Log4j.  Also, thank you to
anyone who takes a moment to answer my questions!  Now on to my questions:



I am integrating Log4j into a new project, but have not been able to resolve
an issue by reading the documentation (perhaps I haven't been reading in the
right places).  Does Log4j read the properties file from the hard drive each
and every time I call the following line of code?

     PropertyConfigurator.configure("MyConfigFile.properties");

I am presuming that PropertyConfigurator.configure() needs to be called only
once per thread, then everything is ready.  Do I understand correctly?

Second question:

In the following code, why is it OK for Category.getInstance("my.category");
to precede PropertyConfigurator.configure("MyConfigFile.properties"); ?
Doesn't getInstance() need the config file to be read in first?



import com.foo.Bar;

 import org.apache.log4j.Category;
 import org.apache.log4j.PropertyConfigurator;

 public class MyApp {

   static Category cat = Category.getInstance(MyApp.class.getName());

   public static void main(String[] args) {


     // BasicConfigurator replaced with PropertyConfigurator.
     PropertyConfigurator.configure(args[0]);

     cat.info("Entering application.");
     Bar bar = new Bar();
     bar.doIt();
     cat.info("Exiting application.");
   }
 }



Thanks and regards,
Mark Buscher
mbuscher@objectframe.com





---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org