Class Logger
- Direct Known Subclasses:
CachingLogger,DefaultLogger,SystemLogger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe log level for debug messages.static final StringThe system property for setting the default log level.static final intThe log level for error messages.static final intThe log level for informational messages.static final StringThe logging catagory for logger messages.static final StringThe system property for setting the category:loglevel mappings.static final intThe log level to indicate no logging, not even errors.static final intThe log level for trace messages.static final intThe log level for warning messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the log levels.abstract voidIssue a debug message.abstract voidIssue an error message.intGet the default log levelGet all of the configured log level categoriesintgetLogLevel(String category) Get the log level for a particular category.abstract voidIssue an informational message.voidSet the log levels by reading system properties.voidsetDefaultLogLevel(int level) Set the default log level.voidsetDefaultLogLevel(String level) Set the default log level.voidsetLogLevel(String category, int level) Set the log level for a particular category.voidsetLogLevel(String category, String level) Set the log level for a particular category.voidsetLogLevels(String config) Set the log levels for a set of categories.abstract voidIssue a trace message.abstract voidIssue a warning message.
-
Field Details
-
logcategory
The logging catagory for logger messages.- See Also:
-
defaultLogLevelProperty
The system property for setting the default log level.- See Also:
-
logLevelsProperty
The system property for setting the category:loglevel mappings.- See Also:
-
SILENT
public static final int SILENTThe log level to indicate no logging, not even errors.- See Also:
-
ERROR
public static final int ERRORThe log level for error messages.- See Also:
-
WARNING
public static final int WARNINGThe log level for warning messages.- See Also:
-
INFO
public static final int INFOThe log level for informational messages.- See Also:
-
DEBUG
public static final int DEBUGThe log level for debug messages.- See Also:
-
TRACE
public static final int TRACEThe log level for trace messages.- See Also:
-
-
Constructor Details
-
Logger
public Logger()
-
-
Method Details
-
readSystemProperties
public void readSystemProperties()Set the log levels by reading system properties.The properties are:
-
Must be an integer specifying the initial default log level or one of the strings "silent", "error", "warning", "info", "debug", or "trace". Absent this property, the default level is 5, or "error".
-
This property specifies a mapping between log categories and the log level for each category. The format of the property is a list of comma or space separated values of the form "category:level". The category "*" sets the default log level.
-
-
getDefaultLogLevel
public int getDefaultLogLevel()Get the default log level- Returns:
- the default log level
-
setDefaultLogLevel
public void setDefaultLogLevel(int level) Set the default log level.If the level is less than zero, it will be set to 0 (silent).
- Parameters:
level- the level
-
setDefaultLogLevel
Set the default log level.The level must be "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used.
- Parameters:
level- the level.- Throws:
NullPointerException- if the level is null.
-
getLogCategories
Get all of the configured log level categories- Returns:
- the set of categories
-
getLogLevel
Get the log level for a particular category.Category names are not case sensitive.
- Parameters:
category- the category- Returns:
- the level
- Throws:
NullPointerException- if the category is null
-
setLogLevel
Set the log level for a particular category.- Parameters:
category- the categorylevel- the level- Throws:
NullPointerException- if the category is null.
-
setLogLevel
Set the log level for a particular category.The level must be "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used.
- Parameters:
category- the category.level- the level.- Throws:
NullPointerException- if the category or level is null.
-
setLogLevels
Set the log levels for a set of categories.The
configspecifies a mapping between log categories and the log level for each category. The format of the string is a list of comma or space separated values of the form "category:level".The level must be an integer or one of "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used. The category "*" sets the default log level.
- Parameters:
config- the category.
-
clearLogLevels
public void clearLogLevels()Clear the log levels.This method removes all configured log levels. All subsequent logging (until more levels are set) will be based entirely on the default log level.
-
error
Issue an error message.- Parameters:
category- the message categoryformat- the format stringparams- message parameters
-
warn
Issue a warning message.- Parameters:
category- the message categoryformat- the format stringparams- message parameters
-
info
Issue an informational message.- Parameters:
category- the message categoryformat- the format stringparams- message parameters
-
debug
Issue a debug message.- Parameters:
category- the message categoryformat- the format stringparams- message parameters
-
trace
Issue a trace message.- Parameters:
category- the message categoryformat- the format stringparams- message parameters
-