messif.utility
Class Logging

java.lang.Object
  extended by messif.utility.Logging

public abstract class Logging
extends java.lang.Object

This class provides functionality to control logging via static methods.


Nested Class Summary
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).
 
Constructor Summary
Logging()
           
 
Method Summary
static void addLogFile(java.lang.String fileName, java.util.logging.Level level, boolean append, boolean useSimpleFormatter)
          Adds a new logging file.
static void addLogFile(java.lang.String fileName, java.util.logging.Level level, boolean append, boolean useSimpleFormatter, java.lang.String regexp, Logging.RegexpFilterAgainst regexpAgainst)
          Adds a new logging file.
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)
          Adds a new logging file.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logging

public Logging()
Method Detail

getRootLogger

protected static java.util.logging.Logger getRootLogger()
Returns the root (top-level) logger from the actual log manager.

Returns:
the top-level logger

setLogLevel

public static void setLogLevel(java.util.logging.Level level)
Set global logging level. Every message, that has higher level is discarded. Note that higher level messages will show neither on console nor in any log file, eventhoug they migh have higher log level set.

Parameters:
level - New global logging level

getLogLevel

public static java.util.logging.Level getLogLevel()
Get global logging level. Values can be found in Level class (OFF, SEVERE, WARNING, INFO, ..., ALL).

Returns:
Current global log level

setLogFileLevel

public static boolean setLogFileLevel(java.lang.String fileName,
                                      java.util.logging.Level level)
Set logging level for an opened log file.

Parameters:
fileName - the name of the log file
level - the new logging level to set
Returns:
true if the logging level was successfuly set for the specified file

setConsoleLevel

public static void setConsoleLevel(java.util.logging.Level level)
Set logging level of the console. If there is no console handler available nothing is modified.

Parameters:
level - the new logging level for console

addLogFile

public 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)
                       throws java.io.IOException
Adds a new logging file.

Parameters:
fileName - the path of the newly opened logging file - can be absolute or relative to the current working directory
level - 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 not
formatter - the formatter instance that will format messages sent to the file; default formater will be used if null
regexp - the regular expression used to filter the messages stored to this log file; if null all messages are stored
regexpAgainst - the part of the log record to match the regexp against
Throws:
java.io.IOException - if there were problems opening the file

addLogFile

public static void addLogFile(java.lang.String fileName,
                              java.util.logging.Level level,
                              boolean append,
                              java.util.logging.Formatter formatter)
                       throws java.io.IOException
Adds a new logging file.

Parameters:
fileName - the path of the newly opened logging file - can be absolute or relative to the current working directory
level - 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 not
formatter - the formatter instance that will format messages sent to the file; default formater will be used if null
Throws:
java.io.IOException - if there were problems opening the file

addLogFile

public static void addLogFile(java.lang.String fileName,
                              java.util.logging.Level level,
                              boolean append,
                              boolean useSimpleFormatter,
                              java.lang.String regexp,
                              Logging.RegexpFilterAgainst regexpAgainst)
                       throws java.io.IOException
Adds a new logging file.

Parameters:
fileName - the path of the newly opened logging file - can be absolute or relative to the current working directory
level - 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 not
useSimpleFormatter - controls whether the SimpleFormatter (if true) or XMLFormatter (if false) is used to format messages sent to the file
regexp - the regular expression used to filter the messages stored to this log file; if null all messages are stored
regexpAgainst - the part of the log record to match the regexp against
Throws:
java.io.IOException - if there were problems opening the file

addLogFile

public static void addLogFile(java.lang.String fileName,
                              java.util.logging.Level level,
                              boolean append,
                              boolean useSimpleFormatter)
                       throws java.io.IOException
Adds a new logging file.

Parameters:
fileName - the path of the newly opened logging file - can be absolute or relative to the current working directory
level - 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 not
useSimpleFormatter - controls whether the SimpleFormatter (if true) or XMLFormatter (if false) is used to format messages sent to the file
Throws:
java.io.IOException - if there were problems opening the file

removeLogFile

public static boolean removeLogFile(java.lang.String fileName)
Close a log file and remove it from logging.

Parameters:
fileName - the name of the log file to remove
Returns:
true if the logging file was successfuly removed