RE: Log4J configuration for library

2004-10-08 Thread Shapira, Yoav

Hi,
First, please be more specific than just "the configuration gets messed up."  Our 
ability to help you is mostly limited by the quality and quantity of the information 
you provide.

The common problem when developing libraries is the need to allow the user of the 
library to configure its logging.  There is code on the log4j wiki that shows you how 
to check if log4j has already been configured.  You can do this check, and then either 
throw a (possibly fatal) exception if log4j is not configured, or configure it 
yourself.  This is a fairly safe approach.

Yoav Shapira
Millennium Research Informatics


>-Original Message-
>From: Nestor Boscan [mailto:[EMAIL PROTECTED]
>Sent: Friday, October 08, 2004 2:26 PM
>To: [EMAIL PROTECTED]
>Subject: Log4J configuration for library
>
>Hi
>
>I'm developing a library and I'm using Log4J. I've had problems with
>applications that use the library and use log4j at the same time. For some
>reason the configuration gets messed up. I'm using a log4j.properties file
>inside de .jar library. Is there a correct way to configure log4j for
>libraries?
>
>Regards,
>
>Néstor Boscán
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


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



RE: Log4J configuration for library

2004-10-08 Thread Vinodh Srinivasasainagendra
I am using BasicConfigurator() to configure my Log4J properties..infact u
can even use PropertyConfigurator() class to configure ur Log4J from an
properties file..example as follows:

 

BasicConfigurator.configure();

 

Or

 

Logger.getLoggerRepository().getRootLogger(new ConsoleAppender(new
PatternLayout("[%d{ISO8601} %-5p][%20.20c][%t] %m%n")));

 

 

If it is a webapp that u are developing u might need to use classloader to
load ur property file. Example as follows:

 

ClassLoader loader = Foo.class.getClassLoader();

loader.getResource("myapp/log4jproperties.txt")));

 

See if this helps

vinodh

 

-Original Message-
From: Nestor Boscan [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 08, 2004 1:26 PM
To: [EMAIL PROTECTED]
Subject: Log4J configuration for library

 

Hi

 

I'm developing a library and I'm using Log4J. I've had problems with

applications that use the library and use log4j at the same time. For some

reason the configuration gets messed up. I'm using a log4j.properties file

inside de .jar library. Is there a correct way to configure log4j for

libraries?

 

Regards,

 

Néstor Boscán

 

 

-

To unsubscribe, e-mail: [EMAIL PROTECTED]

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