public final class LogUtil extends Object
java.util.logging
-related utility methods.Modifier and Type | Field and Description |
---|---|
static Level |
INFO_PLUS_1
|
static Filter |
LESS_THAN_CONFIG
Regards levels less than
Level.CONFIG (e.g. |
static Filter |
LESS_THAN_INFO
Regards levels less than
Level.INFO (e.g. |
static Filter |
LESS_THAN_WARNING
Regards levels less than
Level.WARNING (e.g. |
static LogManager |
LOG_MANAGER
An alternative to repeated calls to
LogManager.getLogManager() . |
static Logger |
ROOT_LOGGER
Is
Logger.getLogger("") . |
static Level |
WARNING_PLUS_1
|
Modifier and Type | Method and Description |
---|---|
static String |
getLoggingProperty(String propertyName) |
static Boolean |
getLoggingProperty(String propertyName,
Boolean defaulT) |
static <T> T |
getLoggingProperty(String propertyName,
Class<T> type)
Evaluates the value of the named property to an object of the given type and returns it.
|
static <T> T |
getLoggingProperty(String propertyName,
Class<T> type,
T defaulT)
Evaluates the value of the named property to an object of the given type and returns it.
|
static Level |
getLoggingProperty(String propertyName,
Level defaulT) |
static long |
getLoggingProperty(String propertyName,
Long defaulT) |
static String |
getLoggingProperty(String propertyName,
String defaulT) |
static Filter |
levelLimitFilter(Level upperBound) |
static Consumer<String> |
logConsumer(Logger logger,
Level level,
String prefix)
Strings passed to the returned
Consumer are logged to the given logger at the given level. |
static Writer |
logWriter(Logger logger,
Level level,
String prefix)
|
static Expression |
parseLoggingProperty(String propertyName,
String... validVariableNames)
Parses an expression from the value of the named logging property.
|
static String |
requireLoggingProperty(String propertyName) |
static <T> T |
requireLoggingProperty(String propertyName,
Class<T> type)
Evaluates the value of the named property to an object of the given type and returns it.
|
public static final LogManager LOG_MANAGER
LogManager.getLogManager()
.public static final Logger ROOT_LOGGER
Logger.getLogger("")
.public static final Level WARNING_PLUS_1
public static final Level INFO_PLUS_1
public static final Filter LESS_THAN_WARNING
Level.WARNING
(e.g. INFO, CONFIG, FINE, FINER, FINEST) as loggable.public static final Filter LESS_THAN_INFO
Level.INFO
(e.g. CONFIG, FINE, FINER, FINEST) as loggable.public static final Filter LESS_THAN_CONFIG
Level.CONFIG
(e.g. FINE, FINER, FINEST) as loggable.public static Consumer<String> logConsumer(Logger logger, Level level, @Nullable String prefix)
Consumer
are logged to the given logger at the given level.prefix
- Is prepended to each string before it is loggedpublic static Filter levelLimitFilter(Level upperBound)
Filter
that regards levels lower than upperBound as loggable@Nullable public static String getLoggingProperty(String propertyName)
null
public static Boolean getLoggingProperty(String propertyName, Boolean defaulT)
@Nullable public static <T> T getLoggingProperty(String propertyName, Class<T> type) throws ParseException, EvaluationException
null
if the logging property is not defined, or if the expression evaluates
to null
EvaluationException
- The value of the property is not assignable to T
ParseException
public static <T> T getLoggingProperty(String propertyName, Class<T> type, T defaulT) throws ParseException, EvaluationException
null
ParseException
EvaluationException
The expression syntax of the property value
public static <T> T requireLoggingProperty(String propertyName, Class<T> type) throws ParseException, EvaluationException
IllegalArgumentException
- The logging property is not definedEvaluationException
- The property evaluates to null
EvaluationException
- The value of the property is not assignable to T
ParseException
public static Level getLoggingProperty(String propertyName, Level defaulT)
IllegalArgumentException
- The value could not be parsed to a valid levelpublic static long getLoggingProperty(String propertyName, Long defaulT)
defaulT
IllegalArgumentException
- The property text cannot be parsed into a LONGpublic static String getLoggingProperty(String propertyName, String defaulT)
public static String requireLoggingProperty(String propertyName)
IllegalArgumentException
- The named logging property is not definedpublic static Expression parseLoggingProperty(String propertyName, String... validVariableNames) throws ParseException
IllegalArgumentException
- The named logging property is not definedParseException
Copyright © 2018 Arno Unkrig. All rights reserved.