com.bankframe.services.logger
Interface ELogger

All Known Implementing Classes:
ConsoleLogger, LOG4JLogger, NullLogger

public interface ELogger

This interface defines the API into the logging service. Create instances of this class as follows:

   import com.bankframe.services.logger.ELogger;
   import com.bankframe.services.logger.ELoggerFactory;

   public class Foo {

   (1)private static final ELogger log = ELoggerFactory.getLogger(Foo.class);

      public void foo() {
           try {
   (2)   log.getContext().push("foo()");
   (3)         if (log.isDebugEnabled()) {
                   log.debug("About to do something to object " + name);
               }
               name.bar();
           } catch (IllegalStateException e) {
   (4)         log.error("Something bad happened to " + name, e);
           } finally {
   (5)          log.getContext().pop("foo()");
           }
       }
 

Notes

  1. Ensure you create a logger for the current class, this ensures that log messages can be filtered by functional area
  2. Calling the log.getContext().push() method adds the supplied string to all subsequent logging methods
  3. Ensure that you call isDebugEnabled() before calling debug messages that involve expensive processing. This ensures run-time performance is not affected by debugging statements
  4. Ensure you use the overloaded version of the logging methods that take an exception as an argument. This ensures that the stack trace for the exception is logged.
  5. Make sure to call the log.getContext().pop() method when you no longer want to add contextual information to each logging message

This interface is based on the API provided by the LOG4J framework


Nested Class Summary
static interface ELogger.Context
          This interface defines the logging context
 
Field Summary
static java.lang.String DEFAULT_CONTEXT
           
 
Method Summary
 void debug(java.lang.String msg)
          This method outputs a DEBUG level message
 void debug(java.lang.String s, java.lang.Throwable throwable)
          This method outputs a DEBUG level message
 void error(java.lang.String s)
          This method outputs a ERROR level message
 void error(java.lang.String s, java.lang.Throwable throwable)
          This method outputs a ERROR level message
 void fatal(java.lang.String s)
          This method outputs a FATAL level message
 void fatal(java.lang.String s, java.lang.Throwable throwable)
          This method outputs a FATAL level message
 ELogger.Context getContext()
          This method returns the Logging context
 void info(java.lang.String s)
          This method outputs a INFO level message
 void info(java.lang.String s, java.lang.Throwable throwable)
          This method outputs a INFO level message
 boolean isDebugEnabled()
          This method indicates whether debug level messages are enabled
 boolean isErrorEnabled()
          This method indicates whether error level messages are enabled
 boolean isFatalEnabled()
          This method indicates whether fatal level messages are enabled
 boolean isInfoEnabled()
          This method indicates whether info level messages are enabled
 boolean isWarnEnabled()
          This method indicates whether warn level messages are enabled
 void warn(java.lang.String s)
          This method outputs a WARN level message
 void warn(java.lang.String s, java.lang.Throwable throwable)
          This method outputs a WARN level message
 

Field Detail

DEFAULT_CONTEXT

public static final java.lang.String DEFAULT_CONTEXT
See Also:
Constant Field Values
Method Detail

isDebugEnabled

public boolean isDebugEnabled()
This method indicates whether debug level messages are enabled


isInfoEnabled

public boolean isInfoEnabled()
This method indicates whether info level messages are enabled


isWarnEnabled

public boolean isWarnEnabled()
This method indicates whether warn level messages are enabled


isErrorEnabled

public boolean isErrorEnabled()
This method indicates whether error level messages are enabled


isFatalEnabled

public boolean isFatalEnabled()
This method indicates whether fatal level messages are enabled


debug

public void debug(java.lang.String msg)
This method outputs a DEBUG level message

Parameters:
msg - The message to print out

debug

public void debug(java.lang.String s,
                  java.lang.Throwable throwable)
This method outputs a DEBUG level message


info

public void info(java.lang.String s)
This method outputs a INFO level message


info

public void info(java.lang.String s,
                 java.lang.Throwable throwable)
This method outputs a INFO level message

Parameters:
throwable - The Throwable associated with this message

warn

public void warn(java.lang.String s)
This method outputs a WARN level message


warn

public void warn(java.lang.String s,
                 java.lang.Throwable throwable)
This method outputs a WARN level message

Parameters:
throwable - The Throwable associated with this message

error

public void error(java.lang.String s)
This method outputs a ERROR level message


error

public void error(java.lang.String s,
                  java.lang.Throwable throwable)
This method outputs a ERROR level message

Parameters:
throwable - The Throwable associated with this message

fatal

public void fatal(java.lang.String s)
This method outputs a FATAL level message


fatal

public void fatal(java.lang.String s,
                  java.lang.Throwable throwable)
This method outputs a FATAL level message

Parameters:
throwable - The Throwable associated with this message

getContext

public ELogger.Context getContext()
This method returns the Logging context



Copyright © 2005, 2007, Oracle. All rights reserved.