Class Logger
- Direct Known Subclasses:
CachingLogger
,DefaultLogger
,SystemLogger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The log level for debug messages.static final String
The system property for setting the default log level.static final int
The log level for error messages.static final int
The log level for informational messages.static final String
The logging catagory for logger messages.static final String
The system property for setting the category:loglevel mappings.static final int
The log level to indicate no logging, not even errors.static final int
The log level for trace messages.static final int
The log level for warning messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the log levels.abstract void
Issue a debug message.abstract void
Issue an error message.int
Get the default log levelGet all of the configured log level categoriesint
getLogLevel
(String category) Get the log level for a particular category.abstract void
Issue an informational message.void
Set the log levels by reading system properties.void
setDefaultLogLevel
(int level) Set the default log level.void
setDefaultLogLevel
(String level) Set the default log level.void
setLogLevel
(String category, int level) Set the log level for a particular category.void
setLogLevel
(String category, String level) Set the log level for a particular category.void
setLogLevels
(String config) Set the log levels for a set of categories.abstract void
Issue a trace message.abstract void
Issue 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
config
specifies 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
-