org.openmdx.application.log
Class AppLog

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

public class AppLog
extends Log

AppLog 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 enablePerformanceLog(boolean enable)
          Deprecated. use Config.enablePerformanceLog(boolean) from the getLogConfig() class
static void enableStatisticsLog(boolean enable)
          Deprecated. use Config.enableStatisticsLog(boolean) from the getLogConfig() class
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 Config getLogConfig()
          Returns the logger's configuration object
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 setApplicationName(String appName)
          Deprecated. use setConfigName(String) instead
static void setConfigName(String cfgName)
          Set the config name that the logs pertain to.
static void setLogLevel(int logLevel)
          Deprecated. use Config.setLogLevel(int) from the getLogConfig() class
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 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(); AppLog.setLogSource(logSource)

Static log source example: AppLog.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 log properties

getLogConfig

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

Returns:
the configuration object

isTraceOn

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

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

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

      if (AppLog.isTraceOn()) {
                summary = expensive_creation();
                detail  = expensive_creation();
          AppLog.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)

setApplicationName

public static void setApplicationName(String appName)
Deprecated. use setConfigName(String) instead

Set the application name string that the logs pertain to. Must be called before doing any logging.

Parameters:
appName - the application name

setLogLevel

public static void setLogLevel(int logLevel)
Deprecated. use Config.setLogLevel(int) from the getLogConfig() class

Set logging level

This method should not be used by applications. The logging level is set in the log property file.

Parameters:
level - a new logging level

enablePerformanceLog

public static void enablePerformanceLog(boolean enable)
Deprecated. use Config.enablePerformanceLog(boolean) from the getLogConfig() class

Enable/Disable performance logging

This method should not be used by applications. The performance log state is set in the log property file.

Parameters:
enable - enable if true

enableStatisticsLog

public static void enableStatisticsLog(boolean enable)
Deprecated. use Config.enableStatisticsLog(boolean) from the getLogConfig() class

Enable/Disable statistics logging

This method should not be used by applications. The statistics log state is set in the log property file.

Parameters:
enable - enable if true


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