public abstract class Logging
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Logging.RegexpFilterAgainst
Enumeration of possible regexp matcher targets for
addLogFile(java.lang.String, java.util.logging.Level, boolean, java.util.logging.Formatter, java.lang.String, messif.utility.Logging.RegexpFilterAgainst, int, int) . |
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Formatter |
oneLineFormatter
Formatter for log messages that prints only date/time + message on a single line
|
Constructor and Description |
---|
Logging() |
Modifier and Type | Method and Description |
---|---|
static void |
addLogFile(java.lang.String fileName,
java.util.logging.Level level,
boolean append,
java.util.logging.Formatter formatter)
Adds a new logging file.
|
static void |
addLogFile(java.lang.String fileName,
java.util.logging.Level level,
boolean append,
java.util.logging.Formatter formatter,
java.lang.String regexp,
Logging.RegexpFilterAgainst regexpAgainst,
int maxSize,
int maxCount)
Adds a new logging file.
|
static void |
addLogFile(java.lang.String fileName,
java.util.logging.Level level,
boolean append,
java.lang.String formatter,
java.lang.String regexp,
Logging.RegexpFilterAgainst regexpAgainst,
int maxSize,
int maxCount,
java.util.Map<java.lang.String,java.lang.Object> namedInstances)
Adds a new logging file.
|
static java.util.logging.Formatter |
createFormatter(java.lang.String value,
java.util.Map<java.lang.String,java.lang.Object> namedInstances)
Creates a formatter for logging files.
|
static java.util.logging.Level |
getLogLevel()
Get global logging level.
|
protected static java.util.logging.Logger |
getRootLogger()
Returns the root (top-level) logger from the actual log manager.
|
static boolean |
removeLogFile(java.lang.String fileName)
Close a log file and remove it from logging.
|
static void |
setConsoleLevel(java.util.logging.Level level)
Set logging level of the console.
|
static boolean |
setLogFileLevel(java.lang.String fileName,
java.util.logging.Level level)
Set logging level for an opened log file.
|
static void |
setLogLevel(java.util.logging.Level level)
Set global logging level.
|
public static final java.util.logging.Formatter oneLineFormatter
protected static java.util.logging.Logger getRootLogger()
public static void setLogLevel(java.util.logging.Level level)
level
- New global logging levelpublic static java.util.logging.Level getLogLevel()
public static boolean setLogFileLevel(java.lang.String fileName, java.util.logging.Level level)
fileName
- the name of the log filelevel
- the new logging level to setpublic static void setConsoleLevel(java.util.logging.Level level)
level
- the new logging level for consolepublic static void addLogFile(java.lang.String fileName, java.util.logging.Level level, boolean append, java.util.logging.Formatter formatter, java.lang.String regexp, Logging.RegexpFilterAgainst regexpAgainst, int maxSize, int maxCount) throws java.io.IOException
fileName
- the path of the newly opened logging file - can be absolute or relative to the current working directorylevel
- the logging level of the file - only messages with lower level will be stored in the file; can be changed by calls to setLogFileLevel(java.lang.String, java.util.logging.Level)
append
- the flag whether the target file should be truncated prior to writing (false) or notformatter
- the formatter instance that will format messages sent to the file; default formatter will be used if nullregexp
- the regular expression used to filter the messages stored to this log file; if null all messages are storedregexpAgainst
- the part of the log record to match the regexp againstmaxSize
- the maximum number of bytes to write to a logging file before it is rotated (zero means unlimited)maxCount
- the number of logging files to use when rotatingjava.io.IOException
- if there were problems opening the filepublic static void addLogFile(java.lang.String fileName, java.util.logging.Level level, boolean append, java.lang.String formatter, java.lang.String regexp, Logging.RegexpFilterAgainst regexpAgainst, int maxSize, int maxCount, java.util.Map<java.lang.String,java.lang.Object> namedInstances) throws java.io.IOException
fileName
- the path of the newly opened logging file - can be absolute or relative to the current working directorylevel
- the logging level of the file - only messages with lower level will be stored in the file; can be changed by calls to setLogFileLevel(java.lang.String, java.util.logging.Level)
append
- the flag whether the target file should be truncated prior to writing (false) or notformatter
- the name of the formatter instance that will format messages sent to the file; default formatter will be used if nullregexp
- the regular expression used to filter the messages stored to this log file; if null all messages are storedregexpAgainst
- the part of the log record to match the regexp againstmaxSize
- the maximum number of bytes to write to a logging file before it is rotated (zero means unlimited)maxCount
- the number of logging files to use when rotatingnamedInstances
- the named instances in which to look for a formatterjava.io.IOException
- if there were problems opening the filepublic static void addLogFile(java.lang.String fileName, java.util.logging.Level level, boolean append, java.util.logging.Formatter formatter) throws java.io.IOException
fileName
- the path of the newly opened logging file - can be absolute or relative to the current working directorylevel
- the logging level of the file - only messages with lower level will be stored in the file; can be changed by calls to setLogFileLevel(java.lang.String, java.util.logging.Level)
append
- the flag whether the target file should be truncated prior to writing (false) or notformatter
- the formatter instance that will format messages sent to the file; default formatter will be used if nulljava.io.IOException
- if there were problems opening the filepublic static java.util.logging.Formatter createFormatter(java.lang.String value, java.util.Map<java.lang.String,java.lang.Object> namedInstances) throws java.lang.IllegalArgumentException
value
- string "true" represents a SimpleFormatter
,
string "false" is translated as XMLFormatter
, and
any other string is looked up in the given namedInstances
namedInstances
- the named instances in which to look for a formatterjava.lang.IllegalArgumentException
- if there was no formatter found for the given value
public static boolean removeLogFile(java.lang.String fileName)
fileName
- the name of the log file to remove