At 11:13 14.02.2001 -0500, you wrote:
>  /**
>   * This method intuits if Log4j got configured correctly by checking if there are
>   * Cateogies, and if the Root Category has at least one Appender setup.
>   * @return boolean True if Log4j is configured properly.
>   */
>  private static boolean isLog4jConfigured()
>  {
>    Enumeration theCats = Category.getCurrentCategories();
>    Enumeration theRootAppenders = Category.getRoot().getAllAppenders();
>    return ( ( theCats.hasMoreElements() ) || ( !( theRootAppenders instanceof 
>org.apache.log4j.helpers.NullEnumeration ) ) );
>  } 

John,

Is isLog4jConfigured() method correct? First and foremost, categories can exist 
without any configurator having ever been called. The first part of the test is 
clearly wrong. Or?

Second, a configuration need not always attach an appender to root, although that is 
not a common situation. 

What is wrong with just having a static boolean, say log4jConfigured, and set it to 
true after calling a configurator? As in:


public class MyLog4jConfigTracker {
  .
  .
  static boolean log4jConfigured = false;

  public 
  // possibly also static 
  void init() {
     ...
     if(!log4jConfigured) {
       configureLog4jMyWay();
       log4jConfigured=true;
     }
  } 
  ...
}

Am I missing something? Cheers, Ceki
> -----Original Message----- 
>From: Pugh, Eric [mailto:[EMAIL PROTECTED]] 
>Sent: Wednesday, February 14, 2001 9:08 AM 
>To: 'LOG4J Users Mailing List' 
>Subject: Related to Some questions 
>
>Hi all, 
>  
>I have a related question.  I have an object that I access via two ways.  This means 
>that the init function is sometimes called twice for the same object.  I call: 
>PropertyConfigurator.configure(new url(PROP_FILE)) twice therefore, and all my 
>logging is duplicated because I have doubled all my appenders. 
>  
>I could always do PropertyConfigurator.resetConfigruation before hand, but that seems 
>slow. 
>  
>How can I see if I have already called the configure method? 
>  
>Eric 
>-----Original Message----- 
>From: Thierry Cools [mailto:[EMAIL PROTECTED]] 
>Sent: Wednesday, February 14, 2001 2:23 AM 
>To: [EMAIL PROTECTED] 
>Subject: Some questions
>
>Hi, I'm a new user of log4j and I have some questions about this tool. 
>  
>I'd like to use Log4j in an EJB environment that is talking to a web-application. 
>My question is, how can I initialize Categories and Proterties, using a XML file or a 
>properties file and be sure that those will be accessible as well to the client side 
>as to the server side. 
>  
>Initialization on the client side can be done in the servlet when my web-application 
>start but for the EJB part I don't know what I will access first. 
>  
>Thanks for your help, 
>Thierry 
>Thierry Cools 
>  
>Senior Java Developer 
>S1 Brussels 
>Kleine Kloosterstraat, 23 
>1932 st. Stevens-Woluwe 
>Belgium 
>Tel : +32 2 200 43 82 
>Email : <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED] 

----
Ceki Gülcü           e-mail: [EMAIL PROTECTED] (preferred)
av. de Rumine 5              [EMAIL PROTECTED]
CH-1005 Lausanne          
Switzerland            Tel: ++41 21 351 23 15


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to