oracle.ias.cache
Class CacheLogger

java.lang.Object
  |
  +--oracle.ias.cache.CacheLogger
Direct Known Subclasses:
DefaultCacheLogger

public abstract class CacheLogger
extends java.lang.Object

CacheLogger is an abstract class. Application can extend this class to implement a customized logging mechanism. The caching service uses this API to log cache related messages. User can use Cache.setLogSeverity(int) to change the desirable cache logging severity. The severities are defined in this class.

A default cache logger is implemented, if no cache logger is provided, the default cache logger will be used. By default, DefaultCacheLogger will log all the messages to a file called "javacache.log" in the directory where the server process started. Users can set a different log file name for the default logger when initializes the cache by calling CacheAttributes.setLogFileName(String).

Since:
2.0.0
See Also:
setLogFileName, DefaultCacheLogger

Field Summary
TypeField
static int DEBUG
           
static int DEFAULT
           
static int ERROR
           
static int FATAL
           
static int INFO
           
protected  java.lang.String logFileName
           
static int OFF
           
protected  int severity
          sets the logging severity.
static int TRACE
           
static int WARNING
           
 
Constructor Summary
CacheLogger()
           
 
Method Summary
TypeMethod
abstract  void flush()
          flush will write out the log messages, and clean the logging buffer.
 java.lang.String getLogFileName()
          returns the log file name defined as logFileName in this class.
 int getSeverity()
          returns the severity level defined as severity in this class.
abstract  void init(java.lang.String fileName, int severity)
          is called by the cache when the logging system is initialized.
abstract  void log(java.lang.String message)
          is an abstract method.
abstract  void log(java.lang.String message, java.lang.Throwable cause)
          is an abstract method.
 void setSeverity(int sev)
          changes the severity level defined as severity in this class.
 boolean shouldLog(int sever)
          returns true if the severity level is such that the message should be logged.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OFF

public static final int OFF

FATAL

public static final int FATAL

ERROR

public static final int ERROR

DEFAULT

public static final int DEFAULT

WARNING

public static final int WARNING

TRACE

public static final int TRACE

INFO

public static final int INFO

DEBUG

public static final int DEBUG

severity

protected int severity
sets the logging severity. If Cache is initialized with a logger, The logger's severity will be used to decide if a cache's message should be logged or not. By doing so, cache can avoid formatting some messages if the system won't log it anyway. This value can be changed by either setSeverity or Cache.setLogSeverity(int) The log level from lower to higher is:

logFileName

protected java.lang.String logFileName
Constructor Detail

CacheLogger

public CacheLogger()
Method Detail

log

public abstract void log(java.lang.String message)
is an abstract method. Application writers can implement this method and provide a mechanism to log a string message.

Parameters:
message - the message need to be logged
Since:
2.0.0

log

public abstract void log(java.lang.String message,
                         java.lang.Throwable cause)
is an abstract method. Sub class should implement this method and provide a mechanism to log a string message and an object which implements the Throwable interface. This is mainly used to log exceptions.

Parameters:
message - The string message need to be logged
cause - An object implements the Throwable interface, usually, it is an exception.
Since:
2.0.0

flush

public abstract void flush()
flush will write out the log messages, and clean the logging buffer.

Since:
2.0.0

init

public abstract void init(java.lang.String fileName,
                          int severity)
                   throws CacheException
is called by the cache when the logging system is initialized. This method will set the initial logging severity and log file name.

Parameters:
fileName - The name of the file to log to
severity - The initial logging severity
Since:
2.0.0

getSeverity

public int getSeverity()
returns the severity level defined as severity in this class.

Returns:
the severity defined in this logger.
Since:
2.0.0

getLogFileName

public java.lang.String getLogFileName()
returns the log file name defined as logFileName in this class.

Returns:
the log file name defined in this logger.
Since:
2.0.0

shouldLog

public boolean shouldLog(int sever)
returns true if the severity level is such that the message should be logged.

Returns:
true if the severity level is such that the message should be logged.
Since:
2.0.0

setSeverity

public void setSeverity(int sev)
changes the severity level defined as severity in this class.

Parameters:
sev - the logging severity
Since:
2.0.0