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 Sara Prigge <sp...@LTCG.com> on 2002/02/27 00:34:36 UTC

What if log4j fails to initialize properly?

I am in the middle of developing a web app that uses log4j.  One unresolved
issue that I need some help on is what happens if log4j fails to initialize
(for example, an incorrect config file name is given)?  I'm using an
initialization servlet (from log4j documentation) that configures the log4j
environment in its init() method like so:

public void init() throws ServletException  {
	String prefix = getServletContext().getRealPath("/");
	String file = getInitParameter("log4j-init-file");
	if (file != null) {
		DOMConfigurator.configureAndWatch(prefix+file);
	}
}

I know that some output is written to the console if a log4j initialization
error occurs.  Can I re-direct that to a file somehow?  In production, if
the initialization servlet fails (file name is null or wrong spelling of
config file, etc.), how will I know it failed?  What happens when the app
reaches code that tries to perform logging?  Bottom line is: When something
goes wrong in my app, I use log4j to log it, but what happens when something
goes wrong with log4j itself?

For development I'm using JBuilder 5 with Tomcat, for production it will be
JRun 3.1.  Someone suggested that possibly within JBuilder I could specify
some parameters to log console output to a file.  I haven't found where I
could do that.....

Maybe I'm making this more difficult than it is??? Any input is appreciated.


Sara Prigge
Web Developer
Long Term Care Group, Inc.
http://www.ltcg.com


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