I think I figured it out.

If the config file is in the classpath you can just use
"-Dlog4j.configuration=<location>".

If the file is *not* in the classpath, you have to specify a protocol
because the initialization is expecting a URL. In my case, this worked:

-Dlog4j.configuration=file:cfg/logger.xml

--Pete

> -----Original Message-----
> From: James Stauffer [mailto:[EMAIL PROTECTED] 
> Sent: Monday, June 13, 2005 7:38 AM
> To: Log4J Users List
> Subject: Re: Default log4j initialization
> 
> Add -log4j.debug to the command line to get more info about how it
> tries to search for the config file.  That should tell you what is
> going wrong.
> 
> On 6/10/05, Ford, Peter <[EMAIL PROTECTED]> wrote:
> > 
> > Hi,
> > 
> > I'm trying to get log4j to initialize when my app starts up, but it
> > doesn't seem to be working.
> > 
> > My command line includes 
> "-Dlog4j.configuration=cfg/logger.xml" and my
> > "main()" method does an explicit call to Logger.getLogger() 
> to force the
> > Logger class to load and hence get the static initializer to run.
> > 
> > It just isn't working. I'm having to follow the getLogger() 
> call with
> > 
> DOMConfigurator.configure(System.getProperty("log4j.configurat
> ion")) to
> > get it to set up. I have no idea what I've missed here.
> > 
> > I'm using log4j 1.2.9; the manual says the default 
> initialization is in
> > the Logger class's static initializer... But when I looked 
> at the source
> > of the Logger class I couldn't find any static initializer 
> (or in the
> > Category class that it extends).
> > 
> > --Pete
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> -- 
> James Stauffer
> Are you good? Take the test at http://www.livingwaters.com/good/
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to