Hi,
You can set the log4j.defaultInitOverride system property (to any value
other than false), and when so configured any log4j.properties or
log4j.xml files on the classpath will be ignored.

However, it might simply be something else doing programmatic
configuration before your code does it.  It's not necessarily the
default init process that's causing this.

Yoav Shapira http://www.yoavshapira.com


>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, November 16, 2004 8:38 AM
>To: Log4J Users List
>Subject: RE: How to determine if log4j has been configured
>
>
>
>
>
>Thanks Paul,
>
>It definately appears that I am picking up a log4j config file from
>somewhere on
>the classpath. And it seems that the call to Logger.getRootLogger() is
>triggering
>log4j to get configured by reading it. So it seems that for me to get
this
>to
>work, my log4j config file must be named something other than
>log4j.properties,
>and I have to make sure that there are *no* other log4j config files
any
>where on
>my classpath.
>
><sigh/>
>
>Dave
>
>We must begin not just to act, but to think, for there is no better
slave
>than the one who believes his slavery to be freedom, and we are in
>no greater peril than when we cannot see the chains on our minds
>because there are yet no chains on our feet.
>-- Michael Reid
>
>
>
>
>
>                      "Paul Smith"
>                      <[EMAIL PROTECTED]         To:      "Log4J Users
List"
><[EMAIL PROTECTED]>
>                      om>                      cc:
>                                               Subject: RE: How to
>determine if log4j has been configured
>                      11/15/2004 04:45
>                      PM
>                      Please respond
>                      to "Log4J Users
>                      List"
>
>
>
>
>
>I believe log4j1.3 has LoggerRepository.isPristine() which will tell
you
>that, but that's not available in the 1.2.8 release.  The only way I
could
>think of doing it is doing as you suggest, and analyzing any attached
>appenders, or checking for any logger in the hierachy that has a
non-null
>Level, which would indicate that it has been 'touched', but this is
>obviously not ideal.
>
>cheers,
>
>Paul Smith
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, November 16, 2004 2:21 AM
>> To: [EMAIL PROTECTED]
>> Subject: How to determine if log4j has been configured
>>
>>
>>
>>
>>
>>
>> I have a number of applications that all derive from a common
>> base class. They
>> also share a log4j.properties file. Because having multiple
>> applications (running
>> in seperate VMs) writing to the same log file is disasterous, I
>> configure log4j
>> in the ctor by calling the property configurator:
>>
>>                   props.load( this
>> .getClass().getClassLoader().getResourceAsStream( "log4j.properties"
) );
>>                   PropertyConfigurator.configure( props );
>>
>> I then enumerate the appenders, and modify any FileAppenders to
specify a
>> sub-class specific log file.
>>
>> This is working fine for applications that run stand-alone.
>> However a couple of
>> these applications run as services under JBoss. In these cases I
>> get an error
>> when trying to log a message . The error is "ERROR: invalid
>> console appender
>> config detected, console stream is looping". I would like to
>> detect if log4j has
>> been configured (by JBoss) before I configure the
>> PropertyConfigurator (and skip
>> that if JBoss has already configured log4j).
>>
>> I tried this code prior to calling the PropertyConfigurator:
>> //          Logger rootLogger = Logger.getRootLogger();
>> //          if( rootLogger == null )
>> //                System.out.println( "Root Logger not yet set!!" );
>> //          else
>> //          {
>> //                System.out.println( "Root logger already set!" );
>> //                Enumeration appenders =
rootLogger.getAllAppenders();
>> //                while( appenders.hasMoreElements() )
>> //                {
>> //                      System.out.println(
>> ((Appender)appenders.nextElement()).getName() );
>> //                }
>> //          }
>>
>> But it said that there were 2 appenders (named FILE and CONSOLE).
>> I'm guessing
>> that getting the root logger (or else the appenders) caused log4j
>> to load a
>> default configuration. So, is there a way I can tell if log4j is
>> configured, and
>> if that configuration is other than the default configuration?
>> Other than by
>> testing for a known named appender specified in the JBoss log4j
>> configuration
>> file (which I really have no control over)?
>>
>> TIA,
>> Dave
>>
>> We must begin not just to act, but to think, for there is no better
slave
>> than the one who believes his slavery to be freedom, and we are in
>> no greater peril than when we cannot see the chains on our minds
>> because there are yet no chains on our feet.
>> -- Michael Reid
>>
>>
>> This message contains information from Equifax Inc. which may be
>> confidential and
>> privileged.  If you are not an intended recipient, please refrain
from
>any
>> disclosure, copying, distribution or use of this information and
>> note that such
>> actions are prohibited.  If you have received this transmission
>> in error, please
>> notify by 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]
>
>
>
>
>
>
>
>This message contains information from Equifax Inc. which may be
>confidential and
>privileged.  If you are not an intended recipient, please refrain from
any
>disclosure, copying, distribution or use of this information and note
that
>such
>actions are prohibited.  If you have received this transmission in
error,
>please
>notify by e-mail [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>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]

Reply via email to