Package org.glassfish.jersey.logging
Class LoggingInterceptor
- java.lang.Object
-
- org.glassfish.jersey.logging.LoggingInterceptor
-
- All Implemented Interfaces:
javax.ws.rs.ext.WriterInterceptor
- Direct Known Subclasses:
ClientLoggingFilter,ServerLoggingFilter
abstract class LoggingInterceptor extends java.lang.Object implements javax.ws.rs.ext.WriterInterceptorAn interceptor that logs an entity if configured so and provides a common logic forClientLoggingFilterandServerLoggingFilter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classLoggingInterceptor.LoggingStreamHelper class used to log an entity to the output stream up to the specified maximum number of bytes.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.atomic.AtomicLong_idprivate static java.util.Comparator<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>>COMPARATOR(package private) static java.lang.StringENTITY_LOGGER_PROPERTYThe entity stream property(package private) java.util.logging.Levellevel(package private) java.util.logging.Loggerlogger(package private) static java.lang.StringLOGGING_ID_PROPERTYLogging record id property(package private) intmaxEntitySizeprivate static java.lang.StringNOTIFICATION_PREFIXprivate static java.util.Set<javax.ws.rs.core.MediaType>READABLE_APP_MEDIA_TYPES(package private) static java.lang.StringREQUEST_PREFIXPrefix will be printed before requests(package private) static java.lang.StringRESPONSE_PREFIXPrefix will be printed before responseprivate static javax.ws.rs.core.MediaTypeTEXT_MEDIA_TYPE(package private) LoggingFeature.Verbosityverbosity
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaroundWriteTo(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 booleanisReadable(javax.ws.rs.core.MediaType mediaType)Returnstrueif specifiedMediaTypeis considered textual.(package private) voidlog(java.lang.StringBuilder b)Logs aStringBuilderparameter at required level.(package private) java.io.InputStreamlogInboundEntity(java.lang.StringBuilder b, java.io.InputStream stream, java.nio.charset.Charset charset)private java.lang.StringBuilderprefixId(java.lang.StringBuilder b, long id)(package private) static booleanprintEntity(LoggingFeature.Verbosity verbosity, javax.ws.rs.core.MediaType mediaType)Returnstrueif entity has to be printed.(package private) voidprintPrefixedHeaders(java.lang.StringBuilder b, long id, java.lang.String prefix, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers)(package private) voidprintRequestLine(java.lang.StringBuilder b, java.lang.String note, long id, java.lang.String method, java.net.URI uri)(package private) voidprintResponseLine(java.lang.StringBuilder b, java.lang.String note, long id, int status)
-
-
-
Field Detail
-
REQUEST_PREFIX
static final java.lang.String REQUEST_PREFIX
Prefix will be printed before requests- See Also:
- Constant Field Values
-
RESPONSE_PREFIX
static final java.lang.String RESPONSE_PREFIX
Prefix will be printed before response- See Also:
- Constant Field Values
-
ENTITY_LOGGER_PROPERTY
static final java.lang.String ENTITY_LOGGER_PROPERTY
The entity stream property
-
LOGGING_ID_PROPERTY
static final java.lang.String LOGGING_ID_PROPERTY
Logging record id property
-
NOTIFICATION_PREFIX
private static final java.lang.String NOTIFICATION_PREFIX
- See Also:
- Constant Field Values
-
TEXT_MEDIA_TYPE
private static final javax.ws.rs.core.MediaType TEXT_MEDIA_TYPE
-
READABLE_APP_MEDIA_TYPES
private static final java.util.Set<javax.ws.rs.core.MediaType> READABLE_APP_MEDIA_TYPES
-
COMPARATOR
private static final java.util.Comparator<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> COMPARATOR
-
logger
final java.util.logging.Logger logger
-
level
final java.util.logging.Level level
-
_id
final java.util.concurrent.atomic.AtomicLong _id
-
verbosity
final LoggingFeature.Verbosity verbosity
-
maxEntitySize
final int maxEntitySize
-
-
Constructor Detail
-
LoggingInterceptor
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.- Parameters:
logger- the logger to log messages to.level- level at which the messages will be logged.verbosity- verbosity of the logged messages. SeeLoggingFeature.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.
-
-
Method Detail
-
log
void log(java.lang.StringBuilder b)
Logs aStringBuilderparameter at required level.- Parameters:
b- message to log
-
prefixId
private java.lang.StringBuilder prefixId(java.lang.StringBuilder b, long id)
-
printRequestLine
void printRequestLine(java.lang.StringBuilder b, java.lang.String note, long id, java.lang.String method, java.net.URI uri)
-
printResponseLine
void printResponseLine(java.lang.StringBuilder b, java.lang.String note, long id, int status)
-
printPrefixedHeaders
void printPrefixedHeaders(java.lang.StringBuilder b, long id, java.lang.String prefix, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers)
-
getSortedHeaders
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)
-
logInboundEntity
java.io.InputStream logInboundEntity(java.lang.StringBuilder b, java.io.InputStream stream, java.nio.charset.Charset charset) throws java.io.IOException- Throws:
java.io.IOException
-
aroundWriteTo
public void aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext writerInterceptorContext) throws java.io.IOException, javax.ws.rs.WebApplicationException- Specified by:
aroundWriteToin interfacejavax.ws.rs.ext.WriterInterceptor- Throws:
java.io.IOExceptionjavax.ws.rs.WebApplicationException
-
isReadable
static boolean isReadable(javax.ws.rs.core.MediaType mediaType)
- Parameters:
mediaType- the media type of the entity- Returns:
trueif specifiedMediaTypeis considered textual.
-
printEntity
static boolean printEntity(LoggingFeature.Verbosity verbosity, javax.ws.rs.core.MediaType mediaType)
Returnstrueif entity has to be printed.- Parameters:
verbosity- the configured verbosity .mediaType- the media type of the payload.- Returns:
trueif entity has to be printed.
-
-