Hi,
What's the isServletAvailable() method look like?

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Inger, Matthew [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, May 26, 2004 4:22 PM
>To: 'Jakarta Commons Developers List'
>Subject: [logging] ServletContextLogger
>
>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]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


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

Reply via email to