com.sap.ip.me.api.logging
Class Trace

java.lang.Object
  extended bycom.sap.ip.me.api.logging.AbstractLogging
      extended bycom.sap.ip.me.api.logging.Trace

public class Trace
extends AbstractLogging

The trace of the Mobile Infrastructure. The Mobile infrastructure manages one trace for all applications only.
This log is disabeld by default and should be used for information and debug purposes. A DefaultFileLogWriter instance is used as default log writer.

Example :
private static final String COMPONENTNAME = "MyApplication/MyComponent" ;
private static Trace trace = Trace.getInstance(COMPONENTNAME);

...
trace.log(Severities.DEBUG, "This is a simple debug message");
trace.log(Severities.DEBUG, "This is a message with some two argument ({0} and {1})", "Object one", Integer.toString(4711 ));
try {
  ...
} catch (Exception e) {
// exception can be logged too   trace.logException(Severities.INFO, "Exception while ...", e, true );
}

Since:
MI 2.5
Author:
SAP
See Also:
Severities, AppLog, AbstractLogging

Field Summary
 
Fields inherited from class com.sap.ip.me.api.logging.AbstractLogging
CONFIGURATION_PREFIX, LOG_ENABLED_SUFFIX, LOG_LEVEL_SUFFIX, LOGWRITER_IMPLEMENTATION_SUFFIX
 
Method Summary
 int getEffectiveSeverity()
          Gets the current log level of the log
static Trace getInstance(java.lang.String componentname)
          Get the singleton instance of the trace.
 java.lang.String getLogName()
          The name of the log will be returned.
protected  LogWriter getLogWriter()
          Returns the LogWriter instance of this log.
protected  java.lang.String getLogWriterClassname()
          Gets the configured filename / path of the log.
 boolean isLogging(int severity)
          Gets the logging attribute of the Trace object
 boolean isOn()
          Gets the current activation state of the log.
protected  void readConfiguration(java.lang.String logName)
          Reads the configuration for the given log.
 void refresh()
          Description of the Method
 void setEffectiveSeverity(int level)
          Gets the current log level of the log
protected  void setLogWriter(LogWriter newLogWriter)
          Sets the LogWriter instance.
protected  void setOn(boolean newon)
          Sets the current activation state of the log.
 boolean switchOn(boolean on)
          Description of the Method
 
Methods inherited from class com.sap.ip.me.api.logging.AbstractLogging
getComponent, getLogContentAsStream, getLogLevelName, getWriter, log, log, log, log, log, log, log, log, log, log, logException, logException, logException, logException, logException, logException, logException, logFileContent, logFileContent, read, releaseWriter, reset, setComponent, writeConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final Trace getInstance(java.lang.String componentname)
Get the singleton instance of the trace.

Parameters:
componentname - Description of the Parameter
Returns:
The singleton instance of the Mobile Infrastructure trace.

isLogging

public final boolean isLogging(int severity)
Gets the logging attribute of the Trace object

Specified by:
isLogging in class AbstractLogging
Parameters:
severity - Description of the Parameter
Returns:
The logging value

switchOn

public boolean switchOn(boolean on)
Description of the Method

Specified by:
switchOn in class AbstractLogging
Parameters:
on - Description of the Parameter
Returns:
Description of the Return Value

getLogName

public java.lang.String getLogName()
The name of the log will be returned.

Returns:
The log name.

refresh

public void refresh()
Description of the Method

Specified by:
refresh in class AbstractLogging

getEffectiveSeverity

public final int getEffectiveSeverity()
Gets the current log level of the log

Specified by:
getEffectiveSeverity in class AbstractLogging
Returns:
The current log level.

setEffectiveSeverity

public void setEffectiveSeverity(int level)
Gets the current log level of the log

Specified by:
setEffectiveSeverity in class AbstractLogging
Parameters:
level - The new effectiveSeverity value

isOn

public final boolean isOn()
Gets the current activation state of the log.

Specified by:
isOn in class AbstractLogging
Returns:
Returns true iff log is on.

getLogWriter

protected LogWriter getLogWriter()
Returns the LogWriter instance of this log.

Specified by:
getLogWriter in class AbstractLogging
Returns:
The LogWriter instance of this log.

setLogWriter

protected void setLogWriter(LogWriter newLogWriter)
Sets the LogWriter instance. Before setting a new LogWriter the old LogWriter instance will be switched off. If the given value is null or it is not an instance of LogWriter an IllegalArgumentException will be thrown and the old log writes resists.

Specified by:
setLogWriter in class AbstractLogging
Parameters:
newLogWriter - The new LogWriter instance

readConfiguration

protected void readConfiguration(java.lang.String logName)
Reads the configuration for the given log. If there is no entry in the configuration these default values will be used:

Specified by:
readConfiguration in class AbstractLogging
Parameters:
logName - The name of the log.

setOn

protected void setOn(boolean newon)
Sets the current activation state of the log.

Specified by:
setOn in class AbstractLogging
Parameters:
newon - The new on value

getLogWriterClassname

protected java.lang.String getLogWriterClassname()
Gets the configured filename / path of the log.

Specified by:
getLogWriterClassname in class AbstractLogging
Returns:
Returns the configured filename / path information of the log.


Copyright © 2005 SAP AG. All Rights Reserved.