[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-user
Subject:    RE: Strange issue with log4j version 1.2.9
From:       Jacob Kjome <hoju () visi ! com>
Date:       2004-12-24 16:18:32
Message-ID: 5.2.1.1.0.20041224095402.03a10e30 () pop ! shell ! visi ! com
[Download RAW message or body]

At 08:57 AM 12/24/2004 -0600, you wrote:
 >  Ok.
 >I found that  there is a library which has log4j.properties in the
 >classpath.
 >This library is used by our app.
 >Is there a way, that the log4j.xml is pulled from where I want rather
 >than the default classpath...
 >

Yes, you are in luck.  If you rename your logger.xml file to log4j.xml, it 
will be picked up in preference to log4j.properties.  Of course this 
doesn't solve the issue if there is another jar in your classpath that has 
log4j.xml in it and is before the directory or jar that contains your own 
log4j.xml.

You can solve this problem by taking Curt's advice and using...

java -Dlog4j.configuration=FIILENAME org.example.myapp.Main


You asked in another email whether you can set a system property.  Well, 
"log4j.configuration" *is* the system property.  The reason to set this via 
the command line is that once the app starts, it is a bit late to attempt 
to set the property since autoconfiguration runs in a static block.  It 
will almost certainly run before you get a chance to set the property 
programmatically.

You can usually solve these issues by making sure the directory or jar 
containing your log4j.xml is first in the classpath.  If you want to simply 
shortcircuit autoconfiguration, put a minimal log4j.xml there and do manual 
configuration yourself at a time your your choosing.  Or, if you are using 
a repository selector and your app is using a logger repository other than 
the default, there isn't any autoconfiguration (in Log4j-1.3, that is) and 
you will need to do it manually anyway.

Jake

 >Thanks
 >Sudhendra (Sudhi) Seshachala
 >Office  : 281-514-0918
 >Cell    : 408-203-9960
 >Mail to: sudhendra.b.seshachala@hp.com
 >
 >-----Original Message-----
 >From: Jacob Kjome [mailto:hoju@visi.com]
 >Sent: Thursday, December 23, 2004 2:50 PM
 >To: Log4J Users List
 >Subject: RE: Strange issue with log4j version 1.2.9
 >
 >At 11:41 AM 12/23/2004 -0600, you wrote:
 > > There is no other config file other than logger.xml.
 > >I do write a java file Logger.java to manually configure logger.xml
 >>instead of default.
 > >Nope. I do not need to specify the root logger level if I don't need
 >to  >  >All these are working, my only issue is that it creates an
 >additional  >RollingFileAppender file type called example.log on my
 >desktop. This is  >along with the configured log file...
 > >
 >
 >I still bet that somewhere, in some jar or other location on your
 >classpath, there is a log4j.properties or log4j.xml that is getting
 >picked up before you are performing manual configuration.  To test this,
 >change your config file to log4j.xml and put it in a directory that is
 >the first thing in the classpath.  I bet the other file doesn't get
 >created anymore.
 >
 >Jake
 >
 > >Thanks
 > >
 > >Sudhendra (Sudhi) Seshachala
 > >Office  : 281-514-0918
 > >Cell    : 408-203-9960
 > >Mail to: sudhendra.b.seshachala@hp.com  >  >-----Original Message-----
 > >From: Jacob Kjome [mailto:hoju@visi.com]
 > >Sent: Thursday, December 23, 2004 11:27 AM
 > >To: Log4J Users List
 > >Subject: Re: Strange issue with log4j version 1.2.9  >  >At 10:27 AM
 >12/23/2004 -0600, you wrote:
 > >
 > >>The logger.xml <<logger.xml>> has has a RollingFileAppender. With
 >file  >>name as c:\application_name-debug.log.
 > >>But another file called example.log gets generated whenever I run the
 >>>application eventhough  I have not configured for this file anywhere..
 > >>
 > >>Can any one help me resolve this&.
 > >
 > >There is obviously another config file in your path which is getting
 >>used in autoconfiguration before it finds your config file.
 > >There is
 > > If you actually name your config file "logger.xml", then there is no
 >>way your file is getting picked up unless you manually configure log4j
 >>yourself.  Rename it to log4j.xml and make sure it is in the default
 >>package in the classpath.  I'm not even sure if your configuration will
 >>work without defining a <root> logger as the last entry in the file
 >>before </log4j:configuration> (in other words, I'm not sure if the
 >>DOMConfigurator will find it valid based on the dtd)?  Also, you should
 >>be using <logger> and <level>, not <category> and <priority>.  The
 >>latter have been deprecated in favor of the former.
 > >
 > >Hope that helps.
 > >
 > >Jake
 > >
 > >
 > >---------------------------------------------------------------------
 > >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 > >For additional commands, e-mail: log4j-user-help@logging.apache.org
 > >
 > >
 > >---------------------------------------------------------------------
 > >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 > >For additional commands, e-mail: log4j-user-help@logging.apache.org
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic