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

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

public class AppLog
extends AbstractLogging

AppLog of the Mobile Infrastructure. Use this log to inform the administrator about unexpected situations on the client. With every synchroization this log will be sent to the backend system (if the log is not empty). Therefore log messages only that can be handled by the administrator. For other messages use the Trace.
The administrator watch the logs on the server. If there are messages with ERROR or FATAL severity the administrator gets a red light, if there are messages with WARNING severity the administrator gets a yellow light.
The default effective severity level for this log is WARNING, the log is activated by default and a DefaultFileLogWriter is used for writing messages.

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

...
try {
  ...
} catch (Exception e) {
  applog.logException(Severities.ERROR, "Exception while ...", e, true );
}

Since:
MI 2.5
Author:
SAP
See Also:
Severities, Trace, 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 AppLog getInstance(java.lang.String componentname)
          Gets the instance attribute of the AppLog class
 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 AppLog object
 boolean isOn()
          Gets the current activation state of the log.
 void log(int severity, java.lang.String message)
          Logs the message if log is switched on and the given severity will be logged.
 void log(int severity, java.lang.String message, java.lang.Object param)
          Logs the message if log is switched on and the given severity will be logged.
 void log(int severity, java.lang.String message, java.lang.Object[] params)
          Logs the message if log is switched on and the given severity will be logged.
 void log(int severity, java.lang.String message, java.lang.Object param1, java.lang.Object param2)
          Logs the message if log is switched on and the given severity will be logged.
 void log(int severity, java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
          Logs the message if log is switched on and the given severity will be logged.
 void log(java.lang.String message)
          Logs the message if log is switched on and severity INFO_LEVEL will be logged.
 void log(java.lang.String message, java.lang.Object param1)
          Logs the message if log is switched on and severity INFO_LEVEL will be logged.
 void log(java.lang.String message, java.lang.Object[] params)
          Logs the message if log is switched on and severity INFO_LEVEL will be logged.
 void log(java.lang.String message, java.lang.Object param1, java.lang.Object param2)
          Logs the message if log is switched on and severity INFO_LEVEL will be logged.
 void log(java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
          Logs the message if log is switched on and severity INFO_LEVEL will be logged.
 void logException(int severity, java.lang.String message, java.lang.Object[] params, java.lang.Throwable t, boolean printStackTrace)
          Logs an Exception with the given message if log is switched on.
 void logException(int severity, java.lang.String message, java.lang.Throwable t, boolean printStackTrace)
          Logs an Exception with the given message if log is switched on.
 void logException(int severity, java.lang.Throwable t)
          Logs an Exception without any additional message if log is switched on.
 void logException(int severity, java.lang.Throwable t, boolean printStackTrace)
          Logs an Exception without any additional message if log is switched on.
 void logException(java.lang.String message, java.lang.Throwable t, boolean printStackTrace)
          Logs an Exception with the given message if log is switched on.
 void logException(java.lang.Throwable t)
          Logs an Exception without any additional message if log is switched on.
 void logException(java.lang.Throwable t, boolean printStackTrace)
          Logs an Exception without any additional message if log is switched on.
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, 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 AppLog getInstance(java.lang.String componentname)
Gets the instance attribute of the AppLog class

Parameters:
componentname - Description of the Parameter
Returns:
The instance value

isLogging

public boolean isLogging(int severity)
Gets the logging attribute of the AppLog 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.

log

public void log(int severity,
                java.lang.String message,
                java.lang.Object param1,
                java.lang.Object param2,
                java.lang.Object param3)
Logs the message if log is switched on and the given severity will be logged. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
param1 - The first parameter for the message. See java.text.MessageFormat .
param2 - The second parameter for the message. See java.text.MessageFormat .
param3 - The third parameter for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(int severity,
                java.lang.String message,
                java.lang.Object param1,
                java.lang.Object param2)
Logs the message if log is switched on and the given severity will be logged. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
param1 - The first parameter for the message. See java.text.MessageFormat .
param2 - The second parameter for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(int severity,
                java.lang.String message,
                java.lang.Object param)
Logs the message if log is switched on and the given severity will be logged. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
param - The parameter for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(int severity,
                java.lang.String message,
                java.lang.Object[] params)
Logs the message if log is switched on and the given severity will be logged. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
params - The parameter list for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(int severity,
                java.lang.String message)
Logs the message if log is switched on and the given severity will be logged. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged.

log

public void log(java.lang.String message,
                java.lang.Object param1,
                java.lang.Object param2,
                java.lang.Object param3)
Logs the message if log is switched on and severity INFO_LEVEL will be logged. The severity for this message is INFO_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
param1 - The first parameter for the message. See java.text.MessageFormat .
param2 - The second parameter for the message. See java.text.MessageFormat .
param3 - The third parameter for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(java.lang.String message,
                java.lang.Object param1,
                java.lang.Object param2)
Logs the message if log is switched on and severity INFO_LEVEL will be logged. The severity for this message is INFO_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
param1 - The first parameter for the message. See java.text.MessageFormat .
param2 - The second parameter for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(java.lang.String message,
                java.lang.Object param1)
Logs the message if log is switched on and severity INFO_LEVEL will be logged. The severity for this message is INFO_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
param1 - The first parameter for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(java.lang.String message,
                java.lang.Object[] params)
Logs the message if log is switched on and severity INFO_LEVEL will be logged. The severity for this message is INFO_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
params - The parameter list for the message. See java.text.MessageFormat .
See Also:
for further details.

log

public void log(java.lang.String message)
Logs the message if log is switched on and severity INFO_LEVEL will be logged. The severity for this message is INFO_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
log in class AbstractLogging
Parameters:
message - The message that has to be logged.

logException

public void logException(int severity,
                         java.lang.String message,
                         java.lang.Object[] params,
                         java.lang.Throwable t,
                         boolean printStackTrace)
Logs an Exception with the given message if log is switched on. The stack trace will not be written to the AppLog. If trace is activated, the message will be written to the trace, too. If the given flag is true the stacktrace of the exception is logged to the trace.

Overrides:
logException in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged. See java.text.MessageFormat for the format of this string.
params - The parameter list for the message. See java.text.MessageFormat .
t - The Throwable that has to be logged.
printStackTrace - Indicates if the stack trace should be printed to the trace.
See Also:
for further details.

logException

public void logException(int severity,
                         java.lang.String message,
                         java.lang.Throwable t,
                         boolean printStackTrace)
Logs an Exception with the given message if log is switched on. The stacktrace of the exception is logged to the trace only if the given flag is true and trace is activated. The message will be logged to the trace also if trace is activated.

Overrides:
logException in class AbstractLogging
Parameters:
severity - The severity for this message.
message - The message that has to be logged.
t - The Throwable that has to be logged.
printStackTrace - Indicates if the stack trace should be printed to the trace.

logException

public void logException(int severity,
                         java.lang.Throwable t,
                         boolean printStackTrace)
Logs an Exception without any additional message if log is switched on. The stacktrace of the exception is logged to the trace only if the given flag is true and trace is activated. The message will be logged to the trace also if trace is activated.

Overrides:
logException in class AbstractLogging
Parameters:
severity - The severity for this message.
t - The Throwable that has to be logged.
printStackTrace - Indicates if the stack trace should be printed to the trace.

logException

public void logException(int severity,
                         java.lang.Throwable t)
Logs an Exception without any additional message if log is switched on. The message will be logged to the trace also if trace is activated. The stacktrace of the exception is logged in trace only.

Overrides:
logException in class AbstractLogging
Parameters:
severity - The severity for this message.
t - The Throwable that has to be logged.

logException

public void logException(java.lang.String message,
                         java.lang.Throwable t,
                         boolean printStackTrace)
Logs an Exception with the given message if log is switched on. The stacktrace of the exception is logged to trace only if the given flag is true and trace is activated. The message will be logged with severity ERROR_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
logException in class AbstractLogging
Parameters:
message - The message that has to be logged.
t - The Throwable that has to be logged.
printStackTrace - Indicates if the stack trace should be printed to the trace.

logException

public void logException(java.lang.Throwable t,
                         boolean printStackTrace)
Logs an Exception without any additional message if log is switched on. The stacktrace of the exception is logged to the trace only if activated. The message will be logged with severity ERROR_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
logException in class AbstractLogging
Parameters:
t - The Throwable that has to be logged.
printStackTrace - Indicates if the stack trace should be printed too.

logException

public void logException(java.lang.Throwable t)
Logs an Exception without any additional message if log is switched on. The stacktrace of the exception is logged to the trace only if activated. The message will be logged with severity ERROR_LEVEL. Logs the message to the trace too, if trace is activated.

Overrides:
logException in class AbstractLogging
Parameters:
t - The Throwable that has to be logged.

refresh

public void refresh()
Description of the Method

Specified by:
refresh in class AbstractLogging

getEffectiveSeverity

public 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 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.