|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.util.logging.Loggers
public class Loggers
Loggers is a class with some static convenience methods to use java logging.
Log configuration is read from a properties file,
"ch/javasoft/logging/Loggers.properties" by default if no other files or
config classes are registered (see LogManager for details).
| Method Summary | |
|---|---|
static Properties |
getDefaultConfigurationAsProperties()
Returns the default configuration for the log manager, see getDefaultConfigurationName(), but as properties object. |
static String |
getDefaultConfigurationName()
Returns the file name of the default configuration, which is ch/javasoft/util/logging/Loggers.properties |
static Logger |
getLogger(Class clazz,
int parts)
Creates a new logger for the given class. |
static Logger |
getLogger(String groupName)
Creates a group logger for the group given by name. |
static Logger |
getLogger(String name,
int parts)
Creates a new logger for the given package. |
static Logger |
getLoggerForPackage(Package pkg,
int parts)
Deprecated. Does not work with MATLAB 7.1.0.246 (R14) Service Pack 3 |
static Logger |
getRootLogger()
Returns the root logger, which is at the root of the parent hierarchy of all group loggers. |
static void |
initLogManagerConfiguration(Properties config)
Initializes the logger configuration with the given configuration properties. |
static boolean |
isLoggable(Logger logger,
Level level)
Returns true if Logger.isLoggable(Level) returns true, the
the logger's filter (if any) would log a
record with the given log level and if any of the installed handlers
would log that record. |
static void |
logToConsole(Level level)
Takes the default configuration
and overrides
.level with the specified log level
handlers with a standard err and
out handler
The log manager is initLogManagerConfiguration(Properties) with
the resulting properties. |
static void |
logToFile(File file,
Level level)
Takes the default configuration
and overrides
.level with the specified log level
handlers with a standard file handler
java.util.logging.FileHandler.pattern with the specified
log file
The log manager is initLogManagerConfiguration(Properties) with
the resulting properties. |
static void |
logToFile(String fileName,
Level level)
Takes the default configuration
and overrides
.level with the specified log level
handlers with a standard file handler
java.util.logging.FileHandler.pattern with the specified
log file
The log manager is initLogManagerConfiguration(Properties) with
the resulting properties. |
static void |
removeAllHandlers(Logger logger,
boolean close)
Removes all handlers of the given logger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Logger getRootLogger()
This is the same as calling Logger.getLogger(String) with
an empty string as logger name. This is a convenience method, which
also ensures that configuration stuff is read before returning the
root logger.
public static Logger getLoggerForPackage(Package pkg,
int parts)
pkg - the packageparts - use 0 for whole package name, positive values for package parts from start (left),
negative values for package parts from end (right)
public static Logger getLogger(Class clazz,
int parts)
clazz - the classparts - use 0 for whole package name, positive values for package parts from start (left),
negative values for package parts from end (right)
public static Logger getLogger(String name,
int parts)
name - the package (or logger) nameparts - use 0 for whole package name, positive values for package parts from start (left),
negative values for package parts from end (right)
public static Logger getLogger(String groupName)
groupName - the name of the log group
public static void logToFile(File file,
Level level)
throws IOException
default configuration
and overrides
file handlerinitLogManagerConfiguration(Properties) with
the resulting properties.
According to the default configuration properties, a
LogFormatter is used by default.
file - The file to log tolevel - The desired log level
SecurityException - if a security manager exists and if
the caller does not have LoggingPermission("control").
IOException - if there are problems reading the propertiesLogManager.readConfiguration(InputStream)
public static void logToFile(String fileName,
Level level)
throws IOException
default configuration
and overrides
file handlerinitLogManagerConfiguration(Properties) with
the resulting properties.
According to the default configuration properties, a
LogFormatter is used by default.
fileName - The file to log tolevel - The desired log level
SecurityException - if a security manager exists and if
the caller does not have LoggingPermission("control").
IOException - if there are problems reading the propertiesLogManager.readConfiguration(InputStream)
public static void logToConsole(Level level)
throws SecurityException,
IOException
default configuration
and overrides
The log manager is initLogManagerConfiguration(Properties) with
the resulting properties.
According to the default configuration properties, WARNING and more
severe messages are now logged on the standard error stream, everything
else on the standard output (if at least as severe as the specified
level). For formatting, a LogFormatter is used by default.
level - The desired log level
SecurityException - if a security manager exists and if
the caller does not have LoggingPermission("control").
IOException - if there are problems reading the propertiesLogManager.readConfiguration(InputStream)
public static boolean isLoggable(Logger logger,
Level level)
Logger.isLoggable(Level) returns true, the
the logger's filter (if any) would log a
record with the given log level and if any of the installed handlers
would log that record.
logger - the logger to test loggability forlevel - the level to check
public static void removeAllHandlers(Logger logger,
boolean close)
logger - the logger of which all handlers should be removedclose - specifies whether the removed handlers should be closedpublic static String getDefaultConfigurationName()
public static void initLogManagerConfiguration(Properties config)
throws SecurityException,
IOException
LogManager.readConfiguration(InputStream).
config - the configuration values
SecurityException - if a security manager exists and if
the caller does not have LoggingPermission("control").
IOException - if there are problems reading the propertiesLogManager.readConfiguration(InputStream)
public static Properties getDefaultConfigurationAsProperties()
throws IOException
getDefaultConfigurationName(), but as properties object. The
properties may be changed and reapplied as logger configuration by
calling initLogManagerConfiguration(Properties).
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||