public final class PerformanceLevel extends Level
SLOW
,
SLOWER
and SLOWEST
- are provided in order to log only the events taking
more than some time duration. For example the console could log only the slowest events,
while a file could log all events considered slow.
Every levels defined in this class have a value between the
Level.FINE
and Level.CONFIG
values. Consequently performance logging are
disabled by default, and enabling them imply enabling configuration logging too. This is
done that way because the configuration typically have a significant impact on performance.
$JAVA_HOME/lib/logging.properties
file can be edited in order to log
messages at the FINE
level, at least for the packages of interest.Logger.setLevel(Level)
can be invoked, together with
Handler.setLevel(Level)
on all relevant logging targets
(console or file, etc.).MonolineFormatter.install(Logger, Level)
convenience
method can be invoked.Defined in the sis-utility
module
Modifier and Type | Field and Description |
---|---|
static PerformanceLevel |
PERFORMANCE
The level for logging all time measurements, regardless of their duration.
|
static PerformanceLevel |
SLOW
The level for logging relatively slow events.
|
static PerformanceLevel |
SLOWER
The level for logging only events slower than the ones logged at the
SLOW level. |
static PerformanceLevel |
SLOWEST
The level for logging only slowest events.
|
Modifier and Type | Method and Description |
---|---|
static PerformanceLevel |
forDuration(long duration,
TimeUnit unit)
Returns the level to use for logging an event of the given duration.
|
long |
getMinDuration(TimeUnit unit)
Returns the minimal duration for logging an event at this level.
|
void |
setMinDuration(long duration,
TimeUnit unit)
Sets the minimal duration for logging an event at this level.
|
equals, getLocalizedName, getName, getResourceBundleName, hashCode, intValue, parse, toString
public static final PerformanceLevel PERFORMANCE
public static final PerformanceLevel SLOW
SLOW.setMinDuration(long, TimeUnit)
.public static final PerformanceLevel SLOWER
SLOW
level.
By default, only events having an execution time equals or greater than 1 second are
logged at this level. However this threshold can be changed by a call to
SLOWER.setMinDuration(long, TimeUnit)
.public static final PerformanceLevel SLOWEST
SLOWEST.setMinDuration(long, TimeUnit)
.public static PerformanceLevel forDuration(long duration, TimeUnit unit)
duration
- the event duration.unit
- the unit of the given duration value.public long getMinDuration(TimeUnit unit)
unit
- the unit in which to express the minimal duration.@Configuration public void setMinDuration(long duration, TimeUnit unit) throws IllegalArgumentException
PERFORMANCE
level can not be modified: it is always zero.
However invoking this method on the PERFORMANCE
field will ensure that every
SLOW*
levels will have at least the given duration.duration
- the minimal duration.unit
- the unit of the given duration value.IllegalArgumentException
- if the given duration is negative.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.