org.glassfish.jersey.filter
Class LoggingFilter

java.lang.Object
  extended by org.glassfish.jersey.filter.LoggingFilter
All Implemented Interfaces:
ClientRequestFilter, ClientResponseFilter, ContainerRequestFilter, ContainerResponseFilter, WriterInterceptor

@PreMatching
public class LoggingFilter
extends Object
implements ContainerRequestFilter, ClientRequestFilter, ContainerResponseFilter, ClientResponseFilter, WriterInterceptor

Universal logging filter. Can be used on client or server side. Has the highest priority.

Author:
Pavel Bucek (pavel.bucek at oracle.com), Martin Matula (martin.matula at oracle.com)

Constructor Summary
LoggingFilter()
          Create a logging filter logging the request and response to a default JDK logger, named as the fully qualified class name of this class.
LoggingFilter(Logger logger, boolean printEntity)
          Create a logging filter with custom logger and custom settings of entity logging.
LoggingFilter(Logger logger, int maxEntitySize)
          Creates a logging filter with custom logger and entity logging turned on, but potentially limiting the size of entity to be buffered and logged.
 
Method Summary
 void aroundWriteTo(WriterInterceptorContext writerInterceptorContext)
           
 void filter(ClientRequestContext context)
           
 void filter(ClientRequestContext requestContext, ClientResponseContext responseContext)
           
 void filter(ContainerRequestContext context)
           
 void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingFilter

public LoggingFilter()
Create a logging filter logging the request and response to a default JDK logger, named as the fully qualified class name of this class. Entity logging is turned off by default.


LoggingFilter

public LoggingFilter(Logger logger,
                     boolean printEntity)
Create a logging filter with custom logger and custom settings of entity logging.

Parameters:
logger - the logger to log requests and responses.
printEntity - if true, entity will be logged as well up to the default maxEntitySize, which is 10KB

LoggingFilter

public LoggingFilter(Logger logger,
                     int maxEntitySize)
Creates a logging filter with custom logger and entity logging turned on, but potentially limiting the size of entity to be buffered and logged.

Parameters:
logger - the logger to log requests and responses.
maxEntitySize - maximum number of entity bytes to be logged (and buffered) - if the entity is larger, logging filter will print (and buffer in memory) only the specified number of bytes and print "...more..." string at the end.
Method Detail

filter

public void filter(ClientRequestContext context)
            throws IOException
Specified by:
filter in interface ClientRequestFilter
Throws:
IOException

filter

public void filter(ClientRequestContext requestContext,
                   ClientResponseContext responseContext)
            throws IOException
Specified by:
filter in interface ClientResponseFilter
Throws:
IOException

filter

public void filter(ContainerRequestContext context)
            throws IOException
Specified by:
filter in interface ContainerRequestFilter
Throws:
IOException

filter

public void filter(ContainerRequestContext requestContext,
                   ContainerResponseContext responseContext)
            throws IOException
Specified by:
filter in interface ContainerResponseFilter
Throws:
IOException

aroundWriteTo

public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext)
                   throws IOException,
                          WebApplicationException
Specified by:
aroundWriteTo in interface WriterInterceptor
Throws:
IOException
WebApplicationException


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.