Class Logger
- java.lang.Object
-
- org.nineml.logging.Logger
-
- Direct Known Subclasses:
CachingLogger
,DefaultLogger
,SystemLogger
public abstract class Logger extends java.lang.Object
The abstract class that all concrete loggers must extend.
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description Logger()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 leveljava.util.Set<java.lang.String>
getLogCategories()
Get all of the configured log level categoriesint
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.
-
-
-
Field Detail
-
logcategory
public static final java.lang.String logcategory
The logging catagory for logger messages.- See Also:
- Constant Field Values
-
defaultLogLevelProperty
public static final java.lang.String defaultLogLevelProperty
The system property for setting the default log level.- See Also:
- Constant Field Values
-
logLevelsProperty
public static final java.lang.String logLevelsProperty
The system property for setting the category:loglevel mappings.- See Also:
- Constant Field Values
-
SILENT
public static final int SILENT
The log level to indicate no logging, not even errors.- See Also:
- Constant Field Values
-
ERROR
public static final int ERROR
The log level for error messages.- See Also:
- Constant Field Values
-
WARNING
public static final int WARNING
The log level for warning messages.- See Also:
- Constant Field Values
-
INFO
public static final int INFO
The log level for informational messages.- See Also:
- Constant Field Values
-
DEBUG
public static final int DEBUG
The log level for debug messages.- See Also:
- Constant Field Values
-
TRACE
public static final int TRACE
The log level for trace messages.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public void setDefaultLogLevel(java.lang.String level)
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:
java.lang.NullPointerException
- if the level is null.
-
getLogCategories
public java.util.Set<java.lang.String> getLogCategories()
Get all of the configured log level categories- Returns:
- the set of categories
-
getLogLevel
public int getLogLevel(java.lang.String category)
Get the log level for a particular category.Category names are not case sensitive.
- Parameters:
category
- the category- Returns:
- the level
- Throws:
java.lang.NullPointerException
- if the category is null
-
setLogLevel
public void setLogLevel(java.lang.String category, int level)
Set the log level for a particular category.- Parameters:
category
- the categorylevel
- the level- Throws:
java.lang.NullPointerException
- if the category is null.
-
setLogLevel
public void setLogLevel(java.lang.String category, java.lang.String level)
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:
java.lang.NullPointerException
- if the category or level is null.
-
setLogLevels
public void setLogLevels(java.lang.String config)
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
public abstract void error(java.lang.String category, java.lang.String format, java.lang.Object... params)
Issue an error message.- Parameters:
category
- the message categoryformat
- the format stringparams
- message parameters
-
warn
public abstract void warn(java.lang.String category, java.lang.String format, java.lang.Object... params)
Issue a warning message.- Parameters:
category
- the message categoryformat
- the format stringparams
- message parameters
-
info
public abstract void info(java.lang.String category, java.lang.String format, java.lang.Object... params)
Issue an informational message.- Parameters:
category
- the message categoryformat
- the format stringparams
- message parameters
-
debug
public abstract void debug(java.lang.String category, java.lang.String format, java.lang.Object... params)
Issue a debug message.- Parameters:
category
- the message categoryformat
- the format stringparams
- message parameters
-
trace
public abstract void trace(java.lang.String category, java.lang.String format, java.lang.Object... params)
Issue a trace message.- Parameters:
category
- the message categoryformat
- the format stringparams
- message parameters
-
-