You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by David Thielen <da...@thielen.com> on 2002/03/29 23:36:45 UTC

Making the log4j library optional

Hi;

Here's my problem. I'm creating a 3rd party library that people will use for their applications. I need to do no logging and I need to not require log4j when they use my library (first, if I log then I fill up their logs with stuff that means nothing to them and second, what if they use an incompatible version of log4j).

But wrapping the log4j calls in a class of my own won't work - because then when strings are logged - it will give the filename and line number of my wrapper method instead of the filename/line number of the place that the log statement was made.

Any ideas? (I'm starting to think I will need a pre-processor that does a #define for the log calls - yuck.)

thanks - dave

Re: Making the log4j library optional

Posted by David Thielen <da...@thielen.com>.
worked - thanks - dave


----- Original Message -----
From: "Ceki Gülcü" <ce...@qos.ch>
To: "Log4J Users List" <lo...@jakarta.apache.org>; "Log4J Users List"
<lo...@jakarta.apache.org>
Sent: Monday, April 01, 2002 3:03 PM
Subject: Re: Making the log4j library optional



Dave,

My proposed solution is to introduce a method such
as the following in your library:

void disableWinWardLogging() {
   if(winWardLoggingEnabled)
      return;

   Category cat = Category.getInstance("net.winward");
   cat.setPriority(Priority.FATAL);

   // In log4j 1.2
   // Logger logger = Logger.getLogger("net.winward");
   // logger.setLevel(Level.OFF);
}

The question is whether your library can call disableWinWardLogging
early in its initialization and how and when the winWardLoggingEnabled
is set.

Please let me know if this approach works for your library.

At 17:30 30.03.2002 -0700, David Thielen wrote:

>----- Original Message -----
>From: "Ceki Gülcü" <ce...@qos.ch>
>To: "Log4J Users List" <lo...@jakarta.apache.org>
>Sent: Saturday, March 30, 2002 3:11 AM
>Subject: Re: Making the log4j library optional
>
>
> > At 15:36 29.03.2002 -0700, you wrote:
> > >Hi;
> > >
> > >Here's my problem. I'm creating a 3rd party library that people will
use
> > >for their applications. I need to do no logging and I need to not
require
> > >log4j when they use my library (first, if I log then I fill up their
logs
> > >with stuff that means nothing to them and second, what if they use an
> > >incompatible version of log4j).
> >
> > First, you would be surprised by the number of libraries that already
> > require log4j. Second, we go to great pains to ensure that all
> > versions of log4j are backward compatible. So I don't understand the
> > comment about incompatible versions of log4j.
>
>Ok, if it's always going to be backward compatible, then that brings me
back
>to my earlier question. How can I tell it to write out nothing for all
>packages in my jar - ie net.windward.*[.*[.*[...]]]. Because if someone is
>using my library, I don't want to fill up their logs with a bunch of stuff
>that means nothing to them. I need this for log4j 1.1 (since I can't
require
>users of my library to switch to 1.2).
>
>thanks - dave

--
Ceki
My link of the month:
http://www.suntimes.com/output/otherviews/cst-edt-ref31.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Making the log4j library optional

Posted by Ceki Gülcü <ce...@qos.ch>.
Dave,

My proposed solution is to introduce a method such
as the following in your library:

void disableWinWardLogging() {
   if(winWardLoggingEnabled)
      return;

   Category cat = Category.getInstance("net.winward");
   cat.setPriority(Priority.FATAL);

   // In log4j 1.2
   // Logger logger = Logger.getLogger("net.winward");
   // logger.setLevel(Level.OFF);
}

The question is whether your library can call disableWinWardLogging
early in its initialization and how and when the winWardLoggingEnabled
is set.

Please let me know if this approach works for your library.

At 17:30 30.03.2002 -0700, David Thielen wrote:

>----- Original Message -----
>From: "Ceki Gülcü" <ce...@qos.ch>
>To: "Log4J Users List" <lo...@jakarta.apache.org>
>Sent: Saturday, March 30, 2002 3:11 AM
>Subject: Re: Making the log4j library optional
>
>
> > At 15:36 29.03.2002 -0700, you wrote:
> > >Hi;
> > >
> > >Here's my problem. I'm creating a 3rd party library that people will use
> > >for their applications. I need to do no logging and I need to not require
> > >log4j when they use my library (first, if I log then I fill up their logs
> > >with stuff that means nothing to them and second, what if they use an
> > >incompatible version of log4j).
> >
> > First, you would be surprised by the number of libraries that already
> > require log4j. Second, we go to great pains to ensure that all
> > versions of log4j are backward compatible. So I don't understand the
> > comment about incompatible versions of log4j.
>
>Ok, if it's always going to be backward compatible, then that brings me back
>to my earlier question. How can I tell it to write out nothing for all
>packages in my jar - ie net.windward.*[.*[.*[...]]]. Because if someone is
>using my library, I don't want to fill up their logs with a bunch of stuff
>that means nothing to them. I need this for log4j 1.1 (since I can't require
>users of my library to switch to 1.2).
>
>thanks - dave

--
Ceki
My link of the month: 
http://www.suntimes.com/output/otherviews/cst-edt-ref31.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Making the log4j library optional

Posted by David Thielen <da...@thielen.com>.
----- Original Message -----
From: "Ceki Gülcü" <ce...@qos.ch>
To: "Log4J Users List" <lo...@jakarta.apache.org>
Sent: Saturday, March 30, 2002 3:11 AM
Subject: Re: Making the log4j library optional


> At 15:36 29.03.2002 -0700, you wrote:
> >Hi;
> >
> >Here's my problem. I'm creating a 3rd party library that people will use
> >for their applications. I need to do no logging and I need to not require
> >log4j when they use my library (first, if I log then I fill up their logs
> >with stuff that means nothing to them and second, what if they use an
> >incompatible version of log4j).
>
> First, you would be surprised by the number of libraries that already
> require log4j. Second, we go to great pains to ensure that all
> versions of log4j are backward compatible. So I don't understand the
> comment about incompatible versions of log4j.

Ok, if it's always going to be backward compatible, then that brings me back
to my earlier question. How can I tell it to write out nothing for all
packages in my jar - ie net.windward.*[.*[.*[...]]]. Because if someone is
using my library, I don't want to fill up their logs with a bunch of stuff
that means nothing to them. I need this for log4j 1.1 (since I can't require
users of my library to switch to 1.2).

thanks - dave


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Making the log4j library optional

Posted by Ceki Gülcü <ce...@qos.ch>.
At 15:36 29.03.2002 -0700, you wrote:
>Hi;
>
>Here's my problem. I'm creating a 3rd party library that people will use 
>for their applications. I need to do no logging and I need to not require 
>log4j when they use my library (first, if I log then I fill up their logs 
>with stuff that means nothing to them and second, what if they use an 
>incompatible version of log4j).

First, you would be surprised by the number of libraries that already
require log4j. Second, we go to great pains to ensure that all
versions of log4j are backward compatible. So I don't understand the
comment about incompatible versions of log4j.

>But wrapping the log4j calls in a class of my own won't work - because 
>then when strings are logged - it will give the filename and line number 
>of my wrapper method instead of the filename/line number of the place that 
>the log statement was made.

I believe Mark has already answered this part of the question.


--
Ceki
My link of the month: http://java.sun.com/aboutJava/standardization/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>