org.olat.core.logging
Class Tracing

java.lang.Object
  extended by org.olat.core.logging.Tracing

public class Tracing
extends java.lang.Object

This is the central place where all log information should pass.

It acts as a facade to the log4j.Logger. Each piece of code, interested to log some error, warning, info, debug message has to do so with the help of the resepective logXYZ(..) method found here.

Using the Tracing class helps to ensure all log messages are built in the same format, and also that they contain all important information like:

The drawback so far is, that the start up information is flooded with "useless" n/a as all code logging outside of a user request does not contain the former listed information.
However, the positive effect of having an easy to use tracing facility from within the code - one line is enough to leave a trace - , and also the fact that each trace is enriched with the user sessions fingerprint, justifies the former described drawback.

Implementation note:

Author:
Felix Jost

Constructor Summary
Tracing()
           
 
Method Summary
static OLog createLoggerFor(java.lang.Class loggingClass)
          Factory method to create a logger object for the given class.
static long getErrorCount()
           
static org.apache.log4j.Logger getLogger(java.lang.Class clazz)
          Deprecated. do use createLoggerFor(..) instead
static java.util.List getLoggers()
           
static java.util.List getLoggersSortedByName()
          generates active loggers list sorted by name.
static boolean isDebugEnabled(java.lang.Class clazz)
          Deprecated. please use OLog log = createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logAudit(java.lang.String logMsg, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logAudit(java.lang.String logMsg, java.lang.String userObj, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logDebug(java.lang.String logMsg, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logDebug(java.lang.String logMsg, java.lang.String userObj, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logError(java.lang.String logMsg, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logError(java.lang.String logMsg, java.lang.Throwable cause, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logInfo(java.lang.String logMsg, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logInfo(java.lang.String logMsg, java.lang.String userObject, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logPerformance(java.lang.String logMsg, java.lang.Class callingClass)
          Add performance log entry
static long logWarn(java.lang.String logMsg, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static long logWarn(java.lang.String logMsg, java.lang.Throwable cause, java.lang.Class callingClass)
          Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.
static void setLevelForAllLoggers(org.apache.log4j.Level logLevel)
          set provided log level for all active loggers.
static void setLevelForLogger(org.apache.log4j.Level logLevel, java.lang.String name)
          set log level of specified logger
static void setUreq(javax.servlet.http.HttpServletRequest ureq)
          sets the HttpServletRequest for the actual click/user request.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tracing

public Tracing()
Method Detail

createLoggerFor

public static OLog createLoggerFor(java.lang.Class loggingClass)
Factory method to create a logger object for the given class. For a certain class always the same logger is returned (shared)

Parameters:
loggingClass -
Returns:

getErrorCount

public static long getErrorCount()
Returns:
long the number of errors since last reboot.

logError

public static long logError(java.lang.String logMsg,
                            java.lang.Throwable cause,
                            java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Add error log entry. See package.html for propper usage!

Parameters:
category -
logMsg -
cause -
Returns:
Log entry identifier.

logError

public static long logError(java.lang.String logMsg,
                            java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Parameters:
callingClass -
logMsg -
Returns:

logWarn

public static long logWarn(java.lang.String logMsg,
                           java.lang.Throwable cause,
                           java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

See package.html for propper usage!

Parameters:
callingClass -
logMsg -
cause -
Returns:

logWarn

public static long logWarn(java.lang.String logMsg,
                           java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Parameters:
callingClass -
logMsg -
Returns:

logDebug

public static long logDebug(java.lang.String logMsg,
                            java.lang.String userObj,
                            java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Add debug log entry. Alwasy use together with if(Tracing.isDebugEnabled()) Tracing.logDebug(...) to let the compiler optimize it for a performance gain

Parameters:
callingClass -
userObj -
logMsg -
Returns:

logDebug

public static long logDebug(java.lang.String logMsg,
                            java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Add debug log entry

Parameters:
callingClass -
logMsg -
Returns:

logInfo

public static long logInfo(java.lang.String logMsg,
                           java.lang.String userObject,
                           java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Parameters:
callingClass -
logMsg -
Returns:

logInfo

public static long logInfo(java.lang.String logMsg,
                           java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Parameters:
callingClass -
logMsg -
Returns:

logAudit

public static long logAudit(java.lang.String logMsg,
                            java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Add audit log entry.

Parameters:
callingClass -
logMsg -
Returns:
Log entry identifier.

logAudit

public static long logAudit(java.lang.String logMsg,
                            java.lang.String userObj,
                            java.lang.Class callingClass)
Deprecated. please use OLog log = Tracing.createLoggerFor(MySample.class) as a private static field in your class and use this log.

Add audit log entry with a user object.

Parameters:
callingClass -
userObj -
logMsg -
Returns:
Log entry identifier.

logPerformance

public static long logPerformance(java.lang.String logMsg,
                                  java.lang.Class callingClass)
Add performance log entry

Parameters:
logMsg -
callingClass -
Returns:
Log entry identifier.

setUreq

public static void setUreq(javax.servlet.http.HttpServletRequest ureq)
sets the HttpServletRequest for the actual click/user request. This method should only be called once per thread(/servlet invocation) and also be the first method call in the void service(HttpServletRequest req, HttpServletResponse resp) or the respective void doXYZ(HttpServletRequest request, HttpServletResponse response) methods.
This method accesses the thread local data store.

Parameters:
ureq -

getLogger

public static org.apache.log4j.Logger getLogger(java.lang.Class clazz)
Deprecated. do use createLoggerFor(..) instead

Returns a log4j logger for this class

Parameters:
clazz -
Returns:
the log4 logger

isDebugEnabled

public static boolean isDebugEnabled(java.lang.Class clazz)
Deprecated. please use OLog log = createLoggerFor(MySample.class) as a private static field in your class and use this log.

if debug log level is enabled for argument

Parameters:
clazz -
Returns:

getLoggers

public static java.util.List getLoggers()
Returns:
list all current loggers

setLevelForAllLoggers

public static void setLevelForAllLoggers(org.apache.log4j.Level logLevel)
set provided log level for all active loggers.

Parameters:
logLevel -

setLevelForLogger

public static void setLevelForLogger(org.apache.log4j.Level logLevel,
                                     java.lang.String name)
set log level of specified logger

Parameters:
logLevel -
name -

getLoggersSortedByName

public static java.util.List getLoggersSortedByName()
generates active loggers list sorted by name.

Returns: