avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tommy Santoso <Tommy.Sant...@osa.de>
Subject ServletOutputLogTarget.java
Date Wed, 28 Feb 2001 11:54:24 GMT
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.

/*
 * 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




Mime
View raw message