Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.progeeks.util.log
Class Log  view Log download Log.java

java.lang.Object
  extended byorg.progeeks.util.log.Log

public class Log
extends java.lang.Object

System logging class. Allows for multiple log levels and a hierarchy of named categories. Each category can have its own log format. Example code:

  public class MyTestClass {
      static Log log = Log.getLog( MyTestClass.class );

      public void someMethod() {
          log.debug( "Entering someMethod()" );
          log.info( "Some operation being performed." );
      }
  }
  

Since:
1.0
Version:
$Revision: 1.1 $

Field Summary
private  org.apache.log4j.Category category
          The log4j Category that this instance of Log writes to
static java.lang.String DEFAULT_CONFIG
           
private static boolean initialized
          Flag set to true if the log class has been initialized.
static java.lang.String KEY_LOG_CONFIG
           
 
Constructor Summary
private Log(org.apache.log4j.Category category)
           
 
Method Summary
 void debug(java.lang.Object message)
          Log a message at the debug priority level.
 void debug(java.lang.Object message, java.lang.Throwable t)
          Log a message at the debug priority level including the stack trace of the specified Throwable.
static void end()
          Threads should call this to remove the diagnostic context before exitting.
 void error(java.lang.Object message)
          Log a message at the error priority level.
 void error(java.lang.Object message, java.lang.Throwable t)
          Log a message at the error priority level including the stack trace of the specified Throwable.
 void fatal(java.lang.Object message)
          Log a message at the fatal priority level.
 void fatal(java.lang.Object message, java.lang.Throwable t)
          Log a message at the fatal priority level including the stack trace of the specified Throwable.
 java.lang.String getCategoryName()
          Returns the current category name for this Log instance.
private static java.util.Properties getDefaultConfiguration()
          Uses dynamic class loading and refelection to attempt to get the configuration class.
static Log getLog(java.lang.Class c)
          Shorthand for getLog( c.getName() );
static Log getLog(java.lang.String categoryName)
          Gets a log instance for writing messages of the specified category.
 void info(java.lang.Object message)
          Log a message at the info priority level.
 void info(java.lang.Object message, java.lang.Throwable t)
          Log a message at the info priority level including the stack trace of the specified Throwable.
static void initialize()
          Initializes the Logger with basic configuration.
 boolean isDebugEnabled()
          Returns true if the current category is logging at the debug level.
 boolean isInfoEnabled()
          Returns true if the current category is logging at the info level.
static java.lang.String pop()
          Clients should call this method before leaving a diagnostic context.
static void push(java.lang.String context)
          Pushes a new diagnostic context onto the context stack.
 void warn(java.lang.Object message)
          Log a message at the warn priority level.
 void warn(java.lang.Object message, java.lang.Throwable t)
          Log a message at the warn priority level including the stack trace of the specified Throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_LOG_CONFIG

public static final java.lang.String KEY_LOG_CONFIG
See Also:
Constant Field Values

DEFAULT_CONFIG

public static final java.lang.String DEFAULT_CONFIG
See Also:
Constant Field Values

category

private org.apache.log4j.Category category
The log4j Category that this instance of Log writes to


initialized

private static boolean initialized
Flag set to true if the log class has been initialized.

Constructor Detail

Log

private Log(org.apache.log4j.Category category)
Method Detail

initialize

public static void initialize()
Initializes the Logger with basic configuration. If the "log.config" System property is set then it will use that value as a configuration file name. Otherwise, the default configuration will be used.


getDefaultConfiguration

private static java.util.Properties getDefaultConfiguration()
Uses dynamic class loading and refelection to attempt to get the configuration class. This allows it to work even if no Configuration.class file exists.


getLog

public static Log getLog(java.lang.String categoryName)
Gets a log instance for writing messages of the specified category. If a name refers to an already retrieved category then the log objects will refer to the same category instance. Note: right now that doesn't make much since, but when log4j is implemented then categories become a very powerful log filter.


getLog

public static Log getLog(java.lang.Class c)
Shorthand for getLog( c.getName() );


push

public static void push(java.lang.String context)
Pushes a new diagnostic context onto the context stack. All logged messages in this thread will now be within this context.


pop

public static java.lang.String pop()
Clients should call this method before leaving a diagnostic context.


end

public static void end()
Threads should call this to remove the diagnostic context before exitting.


getCategoryName

public java.lang.String getCategoryName()
Returns the current category name for this Log instance.


debug

public void debug(java.lang.Object message)
Log a message at the debug priority level.


debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)
Log a message at the debug priority level including the stack trace of the specified Throwable.


error

public void error(java.lang.Object message)
Log a message at the error priority level.


error

public void error(java.lang.Object message,
                  java.lang.Throwable t)
Log a message at the error priority level including the stack trace of the specified Throwable.


fatal

public void fatal(java.lang.Object message)
Log a message at the fatal priority level.


fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable t)
Log a message at the fatal priority level including the stack trace of the specified Throwable.


info

public void info(java.lang.Object message)
Log a message at the info priority level.


info

public void info(java.lang.Object message,
                 java.lang.Throwable t)
Log a message at the info priority level including the stack trace of the specified Throwable.


warn

public void warn(java.lang.Object message)
Log a message at the warn priority level.


warn

public void warn(java.lang.Object message,
                 java.lang.Throwable t)
Log a message at the warn priority level including the stack trace of the specified Throwable.


isDebugEnabled

public boolean isDebugEnabled()
Returns true if the current category is logging at the debug level.


isInfoEnabled

public boolean isInfoEnabled()
Returns true if the current category is logging at the info level.