org.openmdx.kernel.log
Class SysLog

java.lang.Object
  extended by org.openmdx.kernel.log.impl.Log
      extended by org.openmdx.kernel.log.SysLog
All Implemented Interfaces:
MechanismManagerListener, ManageableMechanism

public class SysLog
extends Log

SysLog wraps the Log class to do application-general logging. It provides a singleton accessor, along with lots of handy class method {static} accessors.


Field Summary
 
Fields inherited from class org.openmdx.kernel.log.impl.Log
isMicrosoftVM
 
Method Summary
static void criticalError(String logString)
          Logs a text string at CRITICAL_ERROR_LEVEL.
static void criticalError(String logString, Object logObj)
          Logs a text string at CRITICAL_ERROR_LEVEL.
static void criticalError(String logString, Object logObj, int callStackOff)
          Logs a text string at CRITICAL_ERROR_LEVEL.
static void detail(String logString)
          Logs a text string at DETAIL_LEVEL.
static void detail(String logString, Object logObj)
          Logs a text string at DETAIL_LEVEL.
static void detail(String logString, Object logObj, int callStackOff)
          Logs a text string at DETAIL_LEVEL.
static void error(String logString)
          Logs a text string at ERROR_LEVEL.
static void error(String logString, Object logObj)
          Logs a text string at ERROR_LEVEL.
static void error(String logString, Object logObj, int callStackOff)
          Logs a text string at ERROR_LEVEL.
static ConfigManager getConfigManager()
          Returns the configuration manager.
static Config getLogConfig()
          Returns the logger's configuration object
static Log getLogger()
          Returns the logger
static void info(String logString)
          Logs a text string at INFO_LEVEL.
static void info(String logString, Object logObj)
          Logs a text string at INFO_LEVEL.
static void info(String logString, Object logObj, int callStackOff)
          Logs a text string at INFO_LEVEL.
static boolean isTraceOn()
          Checks if trace logging is active
static void performance(String logString, long elapsedTime)
          Logs a text string and an elapsed time at PERFORMANCE_LEVEL.
static void performance(String logString, long elapsedTime, int callStackOff)
          Logs a text string and an elapsed time at PERFORMANCE_LEVEL.
static void register(Config config)
          Register a Logger by its configuration object.
static void setConfigName(String cfgName)
          Set the config name that the logs pertain to.
static void setLogProperties(Properties props)
          Sets the log properties [Config-Level-3].
static void setLogSource(Object logSource)
          Set a log source object.
static void statistics(String group, String record)
          Logs a text string at STATISTICS_LEVEL.
static void statistics(String group, String record, int callStackOff)
          Logs a text string at STATISTICS_LEVEL.
static void trace(String logString)
          Logs a text string at TRACE_LEVEL.
static void trace(String logString, Object logObj)
          Logs a text string at TRACE_LEVEL.
static void trace(String logString, Object logObj, int callStackOff)
          Logs a text string at TRACE_LEVEL.
static void unregister(Config config)
          Unregister a logger.
static void warning(String logString)
          Logs a text string at WARNING_LEVEL.
static void warning(String logString, Object logObj)
          Logs a text string at WARNING_LEVEL.
static void warning(String logString, Object logObj, int callStackOff)
          Logs a text string at WARNING_LEVEL.
 
Methods inherited from class org.openmdx.kernel.log.impl.Log
finalize, getActiveEntities, getBootstrapLogger, getConfig, getDateOpened, getHostName, getLogClassName, getLoggingLevel, getLogProperties, getMechanismManager, getName, getReadableEntities, getReader, getRemoveableEntities, isBooted, isLoggingPerformance, isLoggingStatistics, loadConfig, loadMechanisms, logEvent, logString, mechanismAddedEvent, mechanismRemovedEvent, newLog, removeEntity, setApplicationControlledTrace, setLoggingLevel, setLoggingPerformance, setLoggingStatistics, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setConfigName

public static void setConfigName(String cfgName)
Set the config name that the logs pertain to. Must be called before doing any logging.

Parameters:
cfgName - a config name

setLogSource

public static void setLogSource(Object logSource)
Set a log source object. The logging framework uses the toString() method to determine the log source for each log event. The object may be set at any time.

Dynamic log source example: class LogSource { public String toString() { return "LogSource-" + System.currentTimeMillis(); } } LogSource logSource = new LogSource(); SysLog.setLogSource(logSource)

Static log source example: SysLog.setLogSource("LogSource")

Parameters:
logSource - a log source object

setLogProperties

public static void setLogProperties(Properties props)
Sets the log properties [Config-Level-3]. setLogProperties() must be called before doing any logging.

Parameters:
properties - the properties

getLogConfig

public static Config getLogConfig()
Returns the logger's configuration object

Returns:
the configuration object

getConfigManager

public static ConfigManager getConfigManager()
Returns the configuration manager. The config manger controls the configuration objects from all loggers currently available in the VM. There is only one configuration manager in a VM.

Returns:
a config manager

isTraceOn

public static boolean isTraceOn()
Checks if trace logging is active

Applications can use this method before they call SysLog.trace(...) if the log string creation is very time consuming.

      SysLog.trace("Customer created", "First=Mark, Last=Smith");

      if (SysLog.isTraceOn()) {
                summary = expensive_creation();
                detail  = expensive_creation();
          SysLog.trace(summary, detail);
        }
 

Returns:
true if trace is active

criticalError

public static void criticalError(String logString,
                                 Object logObj)
Logs a text string at CRITICAL_ERROR_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
See Also:
criticalError(String), criticalError(String, Object, int)

criticalError

public static void criticalError(String logString)
Logs a text string at CRITICAL_ERROR_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
See Also:
criticalError(String, Object), criticalError(String, Object, int)

criticalError

public static void criticalError(String logString,
                                 Object logObj,
                                 int callStackOff)
Logs a text string at CRITICAL_ERROR_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
criticalError(String), criticalError(String, Object)

error

public static void error(String logString,
                         Object logObj)
Logs a text string at ERROR_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
See Also:
error(String), error(String, Object, int)

error

public static void error(String logString)
Logs a text string at ERROR_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
See Also:
error(String, Object), error(String, Object, int)

error

public static void error(String logString,
                         Object logObj,
                         int callStackOff)
Logs a text string at ERROR_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
error(String), error(String, Object)

warning

public static void warning(String logString,
                           Object logObj)
Logs a text string at WARNING_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
See Also:
warning(String), warning(String, Object, int)

warning

public static void warning(String logString)
Logs a text string at WARNING_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
See Also:
warning(String, Object), warning(String, Object, int)

warning

public static void warning(String logString,
                           Object logObj,
                           int callStackOff)
Logs a text string at WARNING_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
warning(String), warning(String, Object)

info

public static void info(String logString,
                        Object logObj)
Logs a text string at INFO_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
See Also:
info(String), info(String, Object, int)

info

public static void info(String logString)
Logs a text string at INFO_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
See Also:
info(String, Object), info(String, Object, int)

info

public static void info(String logString,
                        Object logObj,
                        int callStackOff)
Logs a text string at INFO_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
info(String), info(String, Object)

detail

public static void detail(String logString,
                          Object logObj)
Logs a text string at DETAIL_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
See Also:
detail(String), detail(String, Object, int)

detail

public static void detail(String logString)
Logs a text string at DETAIL_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
See Also:
detail(String, Object), detail(String, Object, int)

detail

public static void detail(String logString,
                          Object logObj,
                          int callStackOff)
Logs a text string at DETAIL_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
detail(String), detail(String, Object)

trace

public static void trace(String logString,
                         Object logObj)
Logs a text string at TRACE_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
See Also:
trace(String), trace(String, Object, int)

trace

public static void trace(String logString)
Logs a text string at TRACE_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
See Also:
trace(String, Object), trace(String, Object, int)

trace

public static void trace(String logString,
                         Object logObj,
                         int callStackOff)
Logs a text string at TRACE_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
logObj - a log object providing detail information. The log object is stringified using its toString method before getting logged. The log object may be a null object. If the log object is a Throwable it's message and stack trace is logged.
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
trace(String), trace(String, Object)

performance

public static void performance(String logString,
                               long elapsedTime)
Logs a text string and an elapsed time at PERFORMANCE_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
elapsedTime - the elapsed time in milli seconds
See Also:
performance(String, long, int)

performance

public static void performance(String logString,
                               long elapsedTime,
                               int callStackOff)
Logs a text string and an elapsed time at PERFORMANCE_LEVEL.

Parameters:
logString - a concise summary message. The message must be single line and must therefore not contain any '\r' or '\n' characters. The '\r' and '\n' characters are removed silently from the message.
elapsedTime - the elapsed time in milli seconds
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
performance(String, long)

statistics

public static void statistics(String group,
                              String record)
Logs a text string at STATISTICS_LEVEL. Statistics messages are grouped. The groups used are defined by the application and do not have any meaning for the logging framework.

Parameters:
group - a statistics group.
info - a statistics record string
See Also:
statistics(String, String, int)

statistics

public static void statistics(String group,
                              String record,
                              int callStackOff)
Logs a text string at STATISTICS_LEVEL. Statistics messages are grouped. The groups used are defined by the application and do not have any meaning for the logging framework.

Parameters:
group - a statistics group.
info - a statistics record string
callStackOff - a call stack correction offset. The offset must be a positive number: 0, 1, 2, 3, ...
See Also:
statistics(String, String)

register

public static void register(Config config)
Register a Logger by its configuration object. All AppLog classes and the SysLog class must register their configuration object. This list of configurations may be used to track the available loggers and to implement dynamic logging configurators.

Parameters:
config - a configuration object that belongs to a static logger class

unregister

public static void unregister(Config config)
Unregister a logger.

Parameters:
config - a configuration object that belongs to a static logger class

getLogger

public static Log getLogger()
Returns the logger

Returns:
a logger


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.