Hi Sara,

I have already posted a message with the same concern. I strongly wanted to
put in production code that does not write Log4J internal errors (such as
config errors) to the standard output, as it does not look very
professional.

1) there is no way to know that a problem occured. For example, if you
intend to use a socket-based appender, and that appender could not be
reached at initialization, you could switch back to a simple file appender
as a 'backup' solution

2) there is no way (at least not in versions prior to 1.2) to redirect the
internal error message. But, you can silent them. The class handling
internal error message is org.apache.log4j.helpers.LogLog.


I thought of using a ErrorHandler, but unfortunaly again, they are intended
to handle internal errors, but configuration errors (the differences between
them is still rather unclear for me).

IMHO, there should be a way to get ALL Log4J errors, at least during
initialization.

Anyway, you can make the needed changes on your own, as source files are
available. That's the magic of open-source...

Hope this helps,

Jean-François Daune

-----Original Message-----
From: Sara Prigge [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 12:35 AM
To: Log4J Users List
Subject: 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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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

Reply via email to