Hi,

As a follow up to this, having to set my own boolean would add to the work
to implement log4j, and require more learning.  I would definitly love to
have a static method tell me if I have loaded the file.

My other question, how do I turn off the automatic look for properties?  I
have all my log property files loaded on a single server, and regardless of
where the app is running, it knows which single server to check.  This means
though that I keep throwing an error everytime I run an app bc is
automatically looks for the property file.

Thanks!
Eric

-----Original Message-----
From: Andy Kriger [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 11:57 AM
To: LOG4J Users Mailing List
Subject: RE: Related to Some questions 


Your suggestion works if you are explicitly calling configure. However, if
you let log4j automatically find the log4j.properties file (a great feature
btw) then you have to do something like checking the root appenders to
verify the properties file was found and read correctly.

Maybe in the next version, there can be a static method somewhere that
returns true if the properties file was loaded?

-----Original Message-----
From: Ceki Gülcü [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 11:51 AM
To: LOG4J Users Mailing List
Subject: RE: Related to Some questions


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]



---------------------------------------------------------------------
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]

Reply via email to