Class TracingLogger
java.lang.Object
org.glassfish.jersey.message.internal.TracingLogger
Low level Tracing support API.
Use one instance per request.
- Since:
- 2.3
- Author:
- Libor Kramolis
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceType of event.static enumLevel of tracing message. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TracingLogger.LevelDefault event level.static final StringRequest header name to switch on request tracing.static final StringRequest header name to set JDK logger name suffix to identify a request logs.static final StringRequest header name to change application default tracing level.static final StringTracingLoggerinstance is placed in request context properties under this name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TracingLoggercreate(TracingLogger.Level threshold, String loggerNameSuffix) Create new Tracing logger.static TracingLoggerempty()Get an empty (no-op) tracing logger instance.abstract voidflush(MultivaluedMap<String, Object> headers) Stores collected tracing messages to response HTTP header.static TracingLoggergetInstance(PropertiesDelegate propertiesDelegate) Returns instance ofTracingLoggerassociated with current request processing (propertiesDelegate).abstract booleanisLogEnabled(TracingLogger.Event event) Test if a tracing support is enabled (according topropertiesDelegatesetting) and ifeventcan be logged (according toevent.leveland threshold level set).abstract voidlog(TracingLogger.Event event, Object... args) Try to log event according to event level and request context threshold level setting.abstract voidlogDuration(TracingLogger.Event event, long fromTimestamp, Object... args) Try to log event according to event level and request context threshold level setting.abstract longtimestamp(TracingLogger.Event event) If logging support is switched on for current request and event setting the method returns current timestamp in nanos.
-
Field Details
-
PROPERTY_NAME
TracingLoggerinstance is placed in request context properties under this name. -
HEADER_THRESHOLD
Request header name to change application default tracing level.- See Also:
-
HEADER_ACCEPT
Request header name to switch on request tracing. Make sense in case of tracing support enabled by ON_DEMAND value.- See Also:
-
HEADER_LOGGER
Request header name to set JDK logger name suffix to identify a request logs.- See Also:
-
DEFAULT_LEVEL
Default event level.
-
-
Constructor Details
-
TracingLogger
public TracingLogger()
-
-
Method Details
-
getInstance
Returns instance ofTracingLoggerassociated with current request processing (propertiesDelegate).- Parameters:
propertiesDelegate- request associated runtime properties. Can benullif not running on server side.- Returns:
- returns instance of
TracingLoggerfrompropertiesDelegate. Does not returnnull.
-
create
Create new Tracing logger.- Parameters:
threshold- tracing level threshold.loggerNameSuffix- tracing logger name suffix.- Returns:
- new tracing logger.
-
empty
Get an empty (no-op) tracing logger instance.- Returns:
- empty tracing logger instance.
-
isLogEnabled
Test if a tracing support is enabled (according topropertiesDelegatesetting) and ifeventcan be logged (according toevent.leveland threshold level set).- Parameters:
event- event type to be tested- Returns:
trueifeventcan be logged
-
log
Try to log event according to event level and request context threshold level setting.- Parameters:
event- event type to be loggedargs- message arguments (in relation to.Event#messageFormat()
-
logDuration
Try to log event according to event level and request context threshold level setting. If logging support is switched on for current request and event setting the method computes duration of event and log message. IffromTimestampis not set (i.e.-1) then duration of event is0.- Parameters:
event- event type to be loggedfromTimestamp- logged event is running from the timestamp in nanos.-1in case event has no durationargs- message arguments (in relation to.Event#messageFormat()
-
timestamp
If logging support is switched on for current request and event setting the method returns current timestamp in nanos.- Parameters:
event- event type to be logged- Returns:
- Current timestamp in nanos or
-1if tracing is not enabled
-
flush
Stores collected tracing messages to response HTTP header.- Parameters:
headers- message headers.
-