Package org.glassfish.jersey.logging
Class LoggingFeature
- java.lang.Object
-
- org.glassfish.jersey.logging.LoggingFeature
-
- All Implemented Interfaces:
javax.ws.rs.core.Feature
public class LoggingFeature extends java.lang.Object implements javax.ws.rs.core.FeatureThis feature enables logging request and/or response on client-side and/or server-side depending on the context'sRuntimeType.The feature may be register programmatically like other features by calling any of
Configurableregister(...)method, i.e.Configurable.register(Class)or by setting any of the configuration property listed bellow.Common configurable properties applies for both client and server and are following:
LOGGING_FEATURE_LOGGER_NAMELOGGING_FEATURE_LOGGER_LEVELLOGGING_FEATURE_VERBOSITYLOGGING_FEATURE_MAX_ENTITY_SIZE
If any of the configuration value is not set, following default values are applied:
- logger name:
org.glassfish.jersey.logging.LoggingFeature - logger level:
Level.FINE - verbosity:
LoggingFeature.Verbosity.PAYLOAD_TEXT - maximum entity size: 8192
Server configurable properties:
Client configurable properties:- Since:
- 2.23
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLoggingFeature.VerbosityVerbositydetermines how detailed message will be logged.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_LOGGER_LEVELDefault logger level which will be used for logging request and response messages.static java.lang.StringDEFAULT_LOGGER_NAMEDefault logger name to log request and response messages.static intDEFAULT_MAX_ENTITY_SIZEDefault maximum entity bytes to be logged.static LoggingFeature.VerbosityDEFAULT_VERBOSITYDefault verbosity for entity logging.private java.util.logging.LoggerfilterLoggerprivate java.util.logging.Levellevelprivate static java.lang.StringLOGGER_LEVEL_POSTFIXprivate static java.lang.StringLOGGER_NAME_POSTFIXprivate static java.lang.StringLOGGING_FEATURE_CLIENT_PREFIXprivate static java.lang.StringLOGGING_FEATURE_COMMON_PREFIXstatic java.lang.StringLOGGING_FEATURE_LOGGER_LEVELCommon logger level property.static java.lang.StringLOGGING_FEATURE_LOGGER_LEVEL_CLIENTClient logger level property.static java.lang.StringLOGGING_FEATURE_LOGGER_LEVEL_SERVERServer logger level property.static java.lang.StringLOGGING_FEATURE_LOGGER_NAMECommon logger name property.static java.lang.StringLOGGING_FEATURE_LOGGER_NAME_CLIENTClient logger name property.static java.lang.StringLOGGING_FEATURE_LOGGER_NAME_SERVERServer logger name property.static java.lang.StringLOGGING_FEATURE_MAX_ENTITY_SIZECommon property for configuring a maximum number of bytes of entity to be logged.static java.lang.StringLOGGING_FEATURE_MAX_ENTITY_SIZE_CLIENTClient property for configuring a maximum number of bytes of entity to be logged.static java.lang.StringLOGGING_FEATURE_MAX_ENTITY_SIZE_SERVERServer property for configuring a maximum number of bytes of entity to be logged.private static java.lang.StringLOGGING_FEATURE_SERVER_PREFIXstatic java.lang.StringLOGGING_FEATURE_VERBOSITYCommon property for configuring a verbosity of entity.static java.lang.StringLOGGING_FEATURE_VERBOSITY_CLIENTClient property for configuring a verbosity of entity.static java.lang.StringLOGGING_FEATURE_VERBOSITY_SERVERServer property for configuring a verbosity of entity.private static java.lang.StringMAX_ENTITY_POSTFIXprivate java.lang.IntegermaxEntitySizeprivate LoggingFeature.Verbosityverbosityprivate static java.lang.StringVERBOSITY_POSTFIX
-
Constructor Summary
Constructors Constructor Description LoggingFeature()Creates the feature with default values.LoggingFeature(java.util.logging.Logger logger)Creates the feature with custom logger.LoggingFeature(java.util.logging.Logger logger, java.lang.Integer maxEntitySize)Creates the feature with custom logger and maximum number of bytes of entity to log.LoggingFeature(java.util.logging.Logger logger, java.util.logging.Level level, LoggingFeature.Verbosity verbosity, java.lang.Integer maxEntitySize)Creates the feature with custom logger, it's level, message verbosity and maximum number of bytes of entity to log.LoggingFeature(java.util.logging.Logger logger, LoggingFeature.Verbosity verbosity)Creates the feature with custom logger and verbosity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconfigure(javax.ws.rs.core.FeatureContext context)private LoggingInterceptorcreateLoggingFilter(javax.ws.rs.core.FeatureContext context, javax.ws.rs.RuntimeType runtimeType)
-
-
-
Field Detail
-
DEFAULT_LOGGER_NAME
public static final java.lang.String DEFAULT_LOGGER_NAME
Default logger name to log request and response messages.
-
DEFAULT_LOGGER_LEVEL
public static final java.lang.String DEFAULT_LOGGER_LEVEL
Default logger level which will be used for logging request and response messages.
-
DEFAULT_MAX_ENTITY_SIZE
public static final int DEFAULT_MAX_ENTITY_SIZE
Default maximum entity bytes to be logged.- See Also:
- Constant Field Values
-
DEFAULT_VERBOSITY
public static final LoggingFeature.Verbosity DEFAULT_VERBOSITY
Default verbosity for entity logging. SeeLoggingFeature.Verbosity.
-
LOGGER_NAME_POSTFIX
private static final java.lang.String LOGGER_NAME_POSTFIX
- See Also:
- Constant Field Values
-
LOGGER_LEVEL_POSTFIX
private static final java.lang.String LOGGER_LEVEL_POSTFIX
- See Also:
- Constant Field Values
-
VERBOSITY_POSTFIX
private static final java.lang.String VERBOSITY_POSTFIX
- See Also:
- Constant Field Values
-
MAX_ENTITY_POSTFIX
private static final java.lang.String MAX_ENTITY_POSTFIX
- See Also:
- Constant Field Values
-
LOGGING_FEATURE_COMMON_PREFIX
private static final java.lang.String LOGGING_FEATURE_COMMON_PREFIX
- See Also:
- Constant Field Values
-
LOGGING_FEATURE_LOGGER_NAME
public static final java.lang.String LOGGING_FEATURE_LOGGER_NAME
Common logger name property.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_LOGGER_LEVEL
public static final java.lang.String LOGGING_FEATURE_LOGGER_LEVEL
Common logger level property.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_VERBOSITY
public static final java.lang.String LOGGING_FEATURE_VERBOSITY
Common property for configuring a verbosity of entity.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_MAX_ENTITY_SIZE
public static final java.lang.String LOGGING_FEATURE_MAX_ENTITY_SIZE
Common property for configuring a maximum number of bytes of entity to be logged.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_SERVER_PREFIX
private static final java.lang.String LOGGING_FEATURE_SERVER_PREFIX
- See Also:
- Constant Field Values
-
LOGGING_FEATURE_LOGGER_NAME_SERVER
public static final java.lang.String LOGGING_FEATURE_LOGGER_NAME_SERVER
Server logger name property.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_LOGGER_LEVEL_SERVER
public static final java.lang.String LOGGING_FEATURE_LOGGER_LEVEL_SERVER
Server logger level property.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_VERBOSITY_SERVER
public static final java.lang.String LOGGING_FEATURE_VERBOSITY_SERVER
Server property for configuring a verbosity of entity.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_MAX_ENTITY_SIZE_SERVER
public static final java.lang.String LOGGING_FEATURE_MAX_ENTITY_SIZE_SERVER
Server property for configuring a maximum number of bytes of entity to be logged.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_CLIENT_PREFIX
private static final java.lang.String LOGGING_FEATURE_CLIENT_PREFIX
- See Also:
- Constant Field Values
-
LOGGING_FEATURE_LOGGER_NAME_CLIENT
public static final java.lang.String LOGGING_FEATURE_LOGGER_NAME_CLIENT
Client logger name property.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_LOGGER_LEVEL_CLIENT
public static final java.lang.String LOGGING_FEATURE_LOGGER_LEVEL_CLIENT
Client logger level property.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_VERBOSITY_CLIENT
public static final java.lang.String LOGGING_FEATURE_VERBOSITY_CLIENT
Client property for configuring a verbosity of entity.- See Also:
- Constant Field Values
-
LOGGING_FEATURE_MAX_ENTITY_SIZE_CLIENT
public static final java.lang.String LOGGING_FEATURE_MAX_ENTITY_SIZE_CLIENT
Client property for configuring a maximum number of bytes of entity to be logged.- See Also:
- Constant Field Values
-
filterLogger
private final java.util.logging.Logger filterLogger
-
verbosity
private final LoggingFeature.Verbosity verbosity
-
maxEntitySize
private final java.lang.Integer maxEntitySize
-
level
private final java.util.logging.Level level
-
-
Constructor Detail
-
LoggingFeature
public LoggingFeature()
Creates the feature with default values.
-
LoggingFeature
public LoggingFeature(java.util.logging.Logger logger)
Creates the feature with custom logger.- Parameters:
logger- the logger to log requests and responses.
-
LoggingFeature
public LoggingFeature(java.util.logging.Logger logger, LoggingFeature.Verbosity verbosity)Creates the feature with custom logger and verbosity.- Parameters:
logger- the logger to log requests and responses.verbosity- verbosity of logged messages. SeeLoggingFeature.Verbosity.
-
LoggingFeature
public LoggingFeature(java.util.logging.Logger logger, java.lang.Integer maxEntitySize)Creates the feature with custom logger and maximum number of bytes of entity to log.- 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. Negative values are interpreted as zero.
-
LoggingFeature
public LoggingFeature(java.util.logging.Logger logger, java.util.logging.Level level, LoggingFeature.Verbosity verbosity, java.lang.Integer maxEntitySize)Creates the feature with custom logger, it's level, message verbosity and maximum number of bytes of entity to log.- Parameters:
logger- the logger to log requests and responses.level- level on which the messages will be logged.verbosity- verbosity of 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
-
configure
public boolean configure(javax.ws.rs.core.FeatureContext context)
- Specified by:
configurein interfacejavax.ws.rs.core.Feature
-
createLoggingFilter
private LoggingInterceptor createLoggingFilter(javax.ws.rs.core.FeatureContext context, javax.ws.rs.RuntimeType runtimeType)
-
-