@PreMatching @Priority(value=-2147483648) public class LoggingFilter extends Object implements ContainerRequestFilter, ClientRequestFilter, ContainerResponseFilter, ClientResponseFilter, WriterInterceptor
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
aroundWriteTo(WriterInterceptorContext writerInterceptorContext)
|
void |
filter(ClientRequestContext context)
Filter method called before a request has been dispatched to a client
transport layer.
|
void |
filter(ClientRequestContext requestContext,
ClientResponseContext responseContext)
Filter method called after a response has been provided for a request
(either by a
request filter or when the
HTTP invocation returns. |
void |
filter(ContainerRequestContext context)
Filter method called before a request has been dispatched to a resource.
|
void |
filter(ContainerRequestContext requestContext,
ContainerResponseContext responseContext)
Filter method called after a response has been provided for a request
(either by a
request filter or by a
matched resource method. |
public LoggingFilter()
public LoggingFilter(Logger logger, boolean printEntity)
logger - the logger to log requests and responses.printEntity - if true, entity will be logged as well up to the default maxEntitySize, which is 8KBpublic LoggingFilter(Logger logger, int maxEntitySize)
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.public void filter(ClientRequestContext context) throws IOException
ClientRequestFilterjavax.annotation.Priority
class-level annotation value.filter in interface ClientRequestFiltercontext - request context.IOException - if an I/O exception occurs.public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException
ClientResponseFilterrequest filter or when the
HTTP invocation returns.
Filters in the filter chain are ordered according to their javax.annotation.Priority
class-level annotation value.filter in interface ClientResponseFilterrequestContext - request context.responseContext - response context.IOException - if an I/O exception occurs.public void filter(ContainerRequestContext context) throws IOException
ContainerRequestFilter
Filters in the filter chain are ordered according to their javax.annotation.Priority
class-level annotation value.
If a request filter produces a response by calling ContainerRequestContext.abortWith(javax.ws.rs.core.Response)
method, the execution of the (either pre-match or post-match) request filter
chain is stopped and the response is passed to the corresponding response
filter chain (either pre-match or post-match). For example, a pre-match
caching filter may produce a response in this way, which would effectively
skip any post-match request filters as well as post-match response filters.
Note however that a responses produced in this manner would still be processed
by the pre-match response filter chain.
filter in interface ContainerRequestFiltercontext - request context.IOException - if an I/O exception occurs.PreMatchingpublic void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException
ContainerResponseFilterrequest filter or by a
matched resource method.
Filters in the filter chain are ordered according to their javax.annotation.Priority
class-level annotation value.
filter in interface ContainerResponseFilterrequestContext - request context.responseContext - response context.IOException - if an I/O exception occurs.public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException
WriterInterceptorMessageBodyWriter.writeTo(T, java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, java.io.OutputStream) method.
The parameters of the wrapped method called are available from context.
Implementations of this method SHOULD explicitly call
WriterInterceptorContext.proceed() to invoke the next interceptor in the chain,
and ultimately the wrapped MessageBodyWriter.writeTo method.aroundWriteTo in interface WriterInterceptorwriterInterceptorContext - invocation context.IOException - if an IO error arises or is thrown by the wrapped
MessageBodyWriter.writeTo method.WebApplicationException - thrown by the wrapped MessageBodyWriter.writeTo method.Copyright © 2007-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.