public abstract class Logger
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG
The log level for debug messages.
|
static java.lang.String |
defaultLogLevelProperty
The system property for setting the default log level.
|
static int |
ERROR
The log level for error messages.
|
static int |
INFO
The log level for informational messages.
|
static java.lang.String |
logcategory
The logging catagory for logger messages.
|
static java.lang.String |
logLevelsProperty
The system property for setting the category:loglevel mappings.
|
static int |
SILENT
The log level to indicate no logging, not even errors.
|
static int |
TRACE
The log level for trace messages.
|
static int |
WARNING
The log level for warning messages.
|
Constructor and Description |
---|
Logger() |
Modifier and Type | Method and Description |
---|---|
void |
clearLogLevels()
Clear the log levels.
|
abstract void |
debug(java.lang.String category,
java.lang.String format,
java.lang.Object... params)
Issue a debug message.
|
abstract void |
error(java.lang.String category,
java.lang.String format,
java.lang.Object... params)
Issue an error message.
|
int |
getDefaultLogLevel()
Get the default log level
|
java.util.Set<java.lang.String> |
getLogCategories()
Get all of the configured log level categories
|
int |
getLogLevel(java.lang.String category)
Get the log level for a particular category.
|
abstract void |
info(java.lang.String category,
java.lang.String format,
java.lang.Object... params)
Issue an informational message.
|
void |
readSystemProperties()
Set the log levels by reading system properties.
|
void |
setDefaultLogLevel(int level)
Set the default log level.
|
void |
setDefaultLogLevel(java.lang.String level)
Set the default log level.
|
void |
setLogLevel(java.lang.String category,
int level)
Set the log level for a particular category.
|
void |
setLogLevel(java.lang.String category,
java.lang.String level)
Set the log level for a particular category.
|
void |
setLogLevels(java.lang.String config)
Set the log levels for a set of categories.
|
abstract void |
trace(java.lang.String category,
java.lang.String format,
java.lang.Object... params)
Issue a trace message.
|
abstract void |
warn(java.lang.String category,
java.lang.String format,
java.lang.Object... params)
Issue a warning message.
|
public static final java.lang.String logcategory
public static final java.lang.String defaultLogLevelProperty
public static final java.lang.String logLevelsProperty
public static final int SILENT
public static final int ERROR
public static final int WARNING
public static final int INFO
public static final int DEBUG
public static final int TRACE
public void readSystemProperties()
The properties are:
defaultLogLevelProperty
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".
logLevelsProperty
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.
public int getDefaultLogLevel()
public void setDefaultLogLevel(int level)
If the level is less than zero, it will be set to 0 (silent).
level
- the levelpublic void setDefaultLogLevel(java.lang.String level)
The level must be "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used.
level
- the level.java.lang.NullPointerException
- if the level is null.public java.util.Set<java.lang.String> getLogCategories()
public int getLogLevel(java.lang.String category)
Category names are not case sensitive.
category
- the categoryjava.lang.NullPointerException
- if the category is nullpublic void setLogLevel(java.lang.String category, int level)
category
- the categorylevel
- the leveljava.lang.NullPointerException
- if the category is null.public void setLogLevel(java.lang.String category, java.lang.String level)
The level must be "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used.
category
- the category.level
- the level.java.lang.NullPointerException
- if the category or level is null.public void setLogLevels(java.lang.String config)
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.
config
- the category.public void clearLogLevels()
This method removes all configured log levels. All subsequent logging (until more levels are set) will be based entirely on the default log level.
public abstract void error(java.lang.String category, java.lang.String format, java.lang.Object... params)
category
- the message categoryformat
- the format stringparams
- message parameterspublic abstract void warn(java.lang.String category, java.lang.String format, java.lang.Object... params)
category
- the message categoryformat
- the format stringparams
- message parameterspublic abstract void info(java.lang.String category, java.lang.String format, java.lang.Object... params)
category
- the message categoryformat
- the format stringparams
- message parameterspublic abstract void debug(java.lang.String category, java.lang.String format, java.lang.Object... params)
category
- the message categoryformat
- the format stringparams
- message parameterspublic abstract void trace(java.lang.String category, java.lang.String format, java.lang.Object... params)
category
- the message categoryformat
- the format stringparams
- message parameters