Anyone have any idea on this? I can't use this approach anyways myself but others 
might find it useful if it can be done.

thanks - dave

  ----- Original Message ----- 
  From: David Thielen 
  To: Log4J Users List 
  Sent: Thursday, March 14, 2002 6:15 PM
  Subject: Re: Turning off my logging programmatically


  Hi;

  I don't think it's item 1 - here is my code:
      Category cat = Category.getInstance("net.winward");
      System.out.println( "cat = " + cat );   
      cat.setPriority(Priority.FATAL);
      System.out.println( "after set" );
  And here is it's output:
      cat = org.apache.log4j.Category@f62373
      after set
      log4j:ERROR No appenders could be found for category 
(net.windward.xmlreport.ProcessReport).
      log4j:ERROR Please initialize the log4j system properly.

  I don't think it's number 2 because I never set the priority except for that one 
time as shown above:
      C:\src\xmlReport\net\windward>qgrep -ynr setPriority "*.java"
      xmlreport\processreport.java:98:                        cat.setPriority(Priority
      .FATAL);

      C:\src\xmlReport\net\windward>

  ????? - dave


  ----- Original Message ----- 
  From: "Ceki Gülcü" <[EMAIL PROTECTED]>
  To: "Log4J Users List" <[EMAIL PROTECTED]>
  Sent: Thursday, March 14, 2002 5:42 PM
  Subject: Re: Turning off my logging programmatically



  Given that ProcessReport is under the net.windward.xmlreport package
  I find the following error messages very stange.
     log4j:ERROR No appenders could be found for category 
  (net.windward.xmlreport.ProcessReport).
     log4j:ERROR Please initia lize the log4j system properly.

  There are two possible explanations. The first explanations is that
  the disabling code, that is:
      Category cat = Category.getInstance("net.winward");
      cat.setPriority(Priority.FATAL);
  is called *after* a logging attempt with ProcessReport.

  The second explanation is that the logger named
  net.windward.xmlreport.ProcessReport or one of its ancestors
  (but below net.winward) is setting its own priority, thus overriding the 
  priority set
  by net.winward. Does that make sense?

  At 15:45 14.03.2002 -0700, David Thielen wrote:
  >The only other log4j code I have is the following in each .java file:
  >
  >     static Category log = Category.getInstance
  >(ProcessReport.class.getName());
  >
  >And log.debug(), log.info(), ... calls throughout.
  >
  >It all works fine if I do call    PropertyConfigurator.configure (
  >propFile ); with my properties file. The problems occurs if I call the code
  >below instead of configure.
  >
  >Any ideas?????
  >
  >thanks - dave
  >
  >
  >----- Original Message -----
  >From: "Ceki Gülcü" <[EMAIL PROTECTED]>
  >To: "Log4J Users List" <[EMAIL PROTECTED]>
  >Sent: Thursday, March 14, 2002 3:38 PM
  >Subject: Re: Turning off my logging programmatically
  >
  >
  >
  >Sorry but this is supposed to work. What are you doing exactly (your code is
  >incomplete right?) and what do you think isn't working?
  >
  >At 14:17 14.03.2002 -0700, David Thielen wrote:
  > >Hi;
  > >
  > >Didn't work. (Well, mostly didn't work.) Here is the code:
  > >
  > >Category cat = Category.getInstance("net.winward");
  > >System.out.println( "cat = " + cat );
  > >cat.setPriority(Priority.FATAL);
  > >
  > >And here is what I got at the console:
  > >
  > >cat = org.apache.log4j.Category@f62373
  > >log4j:ERROR No appenders could be found for category
  > >(net.windward.xmlreport.Pro
  > >cessReport).
  > >log4j:ERROR Please initialize the log4j system properly.
  > >
  > >Any other way?
  > >
  > >thanks - dave
  > >
  > >
  > >----- Original Message -----
  > >From: "Ceki Gülcü" <[EMAIL PROTECTED]>
  > >To: "Log4J Users List" <[EMAIL PROTECTED]>
  > >Sent: Thursday, March 14, 2002 12:59 AM
  > >Subject: Re: Turning off my logging programmatically
  > >
  > >
  > > >
  > > > Have you tried the following?
  > > >
  > > > (in log4j 1.1.x or log4j 1.2)
  > > >
  > > > if(!condition) {
  > > >    Category cat = Category.getInstance("net.winward");
  > > >    cat.setPriority(Priority.FATAL);
  > > > }
  > > >
  > > > (in log4j 1.2 only)
  > > >
  > > > if(!condition) {
  > > >    Logger logger = Logger.getLogger("net.winward");
  > > >    logger.setLogger(Level.OFF);
  > > > }
  > > >
  > > > Hope this helps, Ceki
  > > >
  > > > At 16:42 13.03.2002 -0700, you wrote:
  > > > >Hi all;
  > > > >
  > > > >I have a library that I ship to people as a jar. Here is what I would
  > > like
  > > > >to be able to do:
  > > > >
  > > > >1) If they have a given property set, I use the value of that property
  >as
  > > > >my log4j configuration properties and do a configure with that. Works
  > > great.
  > > > >
  > > > >2) However, if they give me no file, I want to disable all logging
  > > from my
  > > > >library without effecting their code. That means if they are using
  >log4j,
  > > > >I don't effect their settings in any way AND I do no logging. If they
  > > > >don't use log4j, then I want nothing to happen - no logging of any
  > > kind. I
  > > > >tried the following but it dodn't work:
  > > > >
  > > > >    PropertyConfigurator.configure ();
  > > > >    Hierarchy h = new Hierarchy( Category.getInstance ( "net.windward"
  > > ));
  > > > > // all my code is net.windward.*****
  > > > >    h.disableAll();
  > > > >
  > > > >Any ideas?
  > > > >
  > > > >thanks - dave
  > > >
  > > > --
  > > > Ceki
  > > >
  > > >
  > > > --
  > > > To unsubscribe,
  > > e-mail:   <mailto:[EMAIL PROTECTED]>
  > > > For additional commands, e-mail:
  > > <mailto:[EMAIL PROTECTED]>
  > > >
  > > >
  >
  >--
  >Ceki
  >
  >
  >--
  >To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
  >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
  >
  >
  >
  >--
  >To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
  >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

  --
  Ceki


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

Reply via email to