avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: ServletOutputLogTarget.java
Date Wed, 28 Feb 2001 13:48:39 GMT
Tommy Santoso wrote:
> 
> Avalon Developer team,
> 
> I'm using avalon framework at the moment, specially org.apache.log
> package.
> 
> There are some LogTargets supported,  but it doesn't support Servlet
> logging (eg. for tomcat).
> 
> I have created ServletOutputLogTarget class, which has this
> functionality. This is my first contribution for
> 
> avalon-dev, and hope everything goes well.

Thanks.  Now, I don't know if you've noticed, but in Cocoon we created
this LogTarget independently, about three months ago.  It wasn't
incorporated into the root package because we thought that it was
too specific.

Oh, I think the Context is supposed to be Thread Safe.  Even then,
we are sending a single message--it should be ok.

> 
> /*
>  * Copyright (C) The Apache Software Foundation. All rights reserved.
>  *
>  * This software is published under the terms of the Apache Software
> License
>  * version 1.1, a copy of which has been included with this distribution
> in
>  * the LICENSE file.
>  */
> 
> package org.apache.log.output;
> 
> import    javax.servlet.ServletContext;
> import    org.apache.log.output.DefaultOutputLogTarget;
> 
> /**
>  * Generic logging interface. Implementations are based on the strategy
>  * pattern.
>  * @author <a href="mailto:Tommy.Santoso@osa.de">Tommy Santoso</a>
>  */
> public class ServletOutputLogTarget
>      extends DefaultOutputLogTarget
> {
>      private ServletContext context = null;
> 
>      /**
>       * Constructor.
>       *
>       * @param context ServletContext to use for logging.
>       */
>      public ServletOutputLogTarget(ServletContext context)
>      {
>           this.context = context;
>      }
> 
>      /**
>       * Logs message to servlet context log file
>       *
>       * @param message message to log to servlet context log file.
>       */
>      protected void output(final String message)
>      {
>           if (context != null){
>                synchronized(this){
>                     context.log(message);
>                }
>           }
>      }
> }
> 
> Thanks,
> 
> Tommy Santoso
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org

Mime
View raw message