abstract class LoggingInterceptor
extends java.lang.Object
implements javax.ws.rs.ext.WriterInterceptor
ClientLoggingFilter
and ServerLoggingFilter
.Modifier and Type | Class and Description |
---|---|
(package private) class |
LoggingInterceptor.LoggingStream
Helper class used to log an entity to the output stream up to the specified maximum number of bytes.
|
Modifier and Type | Field and Description |
---|---|
(package private) java.util.concurrent.atomic.AtomicLong |
_id |
private static java.util.Comparator<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> |
COMPARATOR |
(package private) static java.lang.String |
ENTITY_LOGGER_PROPERTY
The entity stream property
|
(package private) java.util.logging.Level |
level |
(package private) java.util.logging.Logger |
logger |
(package private) static java.lang.String |
LOGGING_ID_PROPERTY
Logging record id property
|
(package private) int |
maxEntitySize |
private static java.lang.String |
NOTIFICATION_PREFIX |
private static java.util.Set<javax.ws.rs.core.MediaType> |
READABLE_APP_MEDIA_TYPES |
(package private) static java.lang.String |
REQUEST_PREFIX
Prefix will be printed before requests
|
(package private) static java.lang.String |
RESPONSE_PREFIX
Prefix will be printed before response
|
private static javax.ws.rs.core.MediaType |
TEXT_MEDIA_TYPE |
(package private) LoggingFeature.Verbosity |
verbosity |
Constructor and Description |
---|
LoggingInterceptor(java.util.logging.Logger logger,
java.util.logging.Level level,
LoggingFeature.Verbosity verbosity,
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(javax.ws.rs.ext.WriterInterceptorContext writerInterceptorContext) |
(package private) java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> |
getSortedHeaders(java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> headers) |
(package private) static boolean |
isReadable(javax.ws.rs.core.MediaType mediaType)
Returns
true if specified MediaType is considered textual. |
(package private) void |
log(java.lang.StringBuilder b)
Logs a
StringBuilder parameter at required level. |
(package private) java.io.InputStream |
logInboundEntity(java.lang.StringBuilder b,
java.io.InputStream stream,
java.nio.charset.Charset charset) |
private java.lang.StringBuilder |
prefixId(java.lang.StringBuilder b,
long id) |
(package private) static boolean |
printEntity(LoggingFeature.Verbosity verbosity,
javax.ws.rs.core.MediaType mediaType)
Returns
true if entity has to be printed. |
(package private) void |
printPrefixedHeaders(java.lang.StringBuilder b,
long id,
java.lang.String prefix,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers) |
(package private) void |
printRequestLine(java.lang.StringBuilder b,
java.lang.String note,
long id,
java.lang.String method,
java.net.URI uri) |
(package private) void |
printResponseLine(java.lang.StringBuilder b,
java.lang.String note,
long id,
int status) |
static final java.lang.String REQUEST_PREFIX
static final java.lang.String RESPONSE_PREFIX
static final java.lang.String ENTITY_LOGGER_PROPERTY
static final java.lang.String LOGGING_ID_PROPERTY
private static final java.lang.String NOTIFICATION_PREFIX
private static final javax.ws.rs.core.MediaType TEXT_MEDIA_TYPE
private static final java.util.Set<javax.ws.rs.core.MediaType> READABLE_APP_MEDIA_TYPES
private static final java.util.Comparator<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> COMPARATOR
final java.util.logging.Logger logger
final java.util.logging.Level level
final java.util.concurrent.atomic.AtomicLong _id
final LoggingFeature.Verbosity verbosity
final int maxEntitySize
LoggingInterceptor(java.util.logging.Logger logger, java.util.logging.Level level, LoggingFeature.Verbosity verbosity, int maxEntitySize)
logger
- the logger to log messages to.level
- level at which the messages will be logged.verbosity
- verbosity of the logged messages. See LoggingFeature.Verbosity
.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. Negative values are interpreted as zero.void log(java.lang.StringBuilder b)
StringBuilder
parameter at required level.b
- message to logprivate java.lang.StringBuilder prefixId(java.lang.StringBuilder b, long id)
void printRequestLine(java.lang.StringBuilder b, java.lang.String note, long id, java.lang.String method, java.net.URI uri)
void printResponseLine(java.lang.StringBuilder b, java.lang.String note, long id, int status)
void printPrefixedHeaders(java.lang.StringBuilder b, long id, java.lang.String prefix, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers)
java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> getSortedHeaders(java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> headers)
java.io.InputStream logInboundEntity(java.lang.StringBuilder b, java.io.InputStream stream, java.nio.charset.Charset charset) throws java.io.IOException
java.io.IOException
public void aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext writerInterceptorContext) throws java.io.IOException, javax.ws.rs.WebApplicationException
aroundWriteTo
in interface javax.ws.rs.ext.WriterInterceptor
java.io.IOException
javax.ws.rs.WebApplicationException
static boolean isReadable(javax.ws.rs.core.MediaType mediaType)
mediaType
- the media type of the entitytrue
if specified MediaType
is considered textual.static boolean printEntity(LoggingFeature.Verbosity verbosity, javax.ws.rs.core.MediaType mediaType)
true
if entity has to be printed.verbosity
- the configured verbosity .mediaType
- the media type of the payload.true
if entity has to be printed.