Is there any call for a Log implementation which will log
to a javax.servlet.ServletContext object? I think it would
be good to provide. It could fit in between the LogFactoryImpl
right before simple logger:
if ((logClassName == null) && isJdk13LumberjackAvailable()) {
logClassName =
"org.apache.commons.logging.impl.Jdk13LumberjackLogger";
}
if (logClassName == null && isServletAvailable()) {
logClassName =
"org.apache.commons.logging.impl.ServletContextLogger";
}
if (logClassName == null) {
logClassName = "org.apache.commons.logging.impl.SimpleLog";
}
As far as initialization, it could provide a static method (since there's
only ever
one ServletContext per web app anyway, a static variable will suffice),
which could
be called from the Servlet's init method. (I'm open to other suggestions
here, but
it's the only way i see to make this happen)
public class ServletContextLogger {
private static ServletContext context;
public static synchronized init(ServletContext context) {
ServletContextLogger.context = context;
}
...
}
If the context has not yet been set, we can do one of two things, and
i'm not sure what the appropriate thing to do is:
1. do nothing when a log message is issued
public void debug(Object message) {
if (context != null) {
context.log(toString(message));
}
}
2. create a SimpleLog for every ServletContextLog, and log the
message to that SimpleLog instance
public void debug(Object message) {
if (context != null) {
context.log(toString(message));
}
else {
simpleLogger.debug(message);
}
}
Any thoughts?
PS: I'm also willing to create a new implementation of LogFactory which
will discover the available log implementations at runtime, rather than the
compile time strategy which exists now.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]