On 26 May 2004, at 21:22, Inger, Matthew wrote:

hi matthew

<snip>

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;
   }

   ...
}

the code you propose is unlikely to be safe in a servlet container environment. you'd have to use a per-context-classloader singleton. ideally, this would have to be held in a weak hashmap (to ensure that the context is garbage collection) but probably this should be discovered at runtime to allow better compatibility.


i'd probably not see this as part of the default logging compile time search (due to the fact that this registration stage is needed) but could be a good addition as an optional logger.

it may be a good idea to wait until after the upcoming 1.0.4 release before adding any new loggers.

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.

sounds interesting. the idea of using commons-discovery to find all implementation at runtime has come up before but AFAIK without much action.


- robert


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



Reply via email to