Arch4J 1.1

org.arch4j.logging
Class LoggingProvider

java.lang.Object
  |
  +--org.arch4j.logging.LoggingProvider
All Implemented Interfaces:
LoggingConstants

public class LoggingProvider
extends Object
implements LoggingConstants

This class is the main service provider for logging services. The services are accessed via the static getProvider() method. Typically, a logging category for a class is retrieved with code that looks like the following:

 public class MyClass {
   static LoggingCategory loggingCategory =
     LoggingProvider.getProvider().getCategory(MyClass.class.getName());
   ...
   public void aMethod() {
     loggingCategory.info("Entered method.");
   }
 }
 

The logging category can then be used to do the logging, using the methods available on LoggingCategory.

Additionally, there is a method named logSystemError(java.lang.String, java.lang.Throwable) that can be called directly on the provider to report system errors. Typically, this would only be used during statup or shutdown, or when the state of the system is in question. This method by-passes the logging manager (and any property lookup that it might use) to write a system-level error message directly to a failsafe category named system.

The reason the class is implemented the way it is is so that in the future, a static initialization block could be used to create the static instance, say via a property file. The manager could also be replaced with another class that implements the LoggingManager interface.

Version:
$Revision: 1.5 $
Author:
Ross E. Greinke

Field Summary
 
Fields inherited from interface org.arch4j.logging.LoggingConstants
DEBUG_LEVEL, ERROR_LEVEL, INFO_LEVEL, LOGGING_DOMAIN, WARNING_LEVEL
 
Method Summary
 void configure()
          Configure the logging framework.
 LoggingCategory getCategory(String name)
          Retrieve a logging category with name name.
static LoggingProvider getProvider()
          Returns the single instance of the LoggingProvider.
 void logSystemError(String message, Throwable thrown)
          Log a system-level error message.
static void resetProvider()
          Reset the single instance of the LoggingProvider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProvider

public static LoggingProvider getProvider()
Returns the single instance of the LoggingProvider.

Returns:
The single instance of the LoggingProvider.

resetProvider

public static void resetProvider()
Reset the single instance of the LoggingProvider.


getCategory

public LoggingCategory getCategory(String name)
Retrieve a logging category with name name.

Parameters:
name - The name of the logging category to retrieve.
Returns:
The logging category to be used for logging.

configure

public void configure()
Configure the logging framework.


logSystemError

public void logSystemError(String message,
                           Throwable thrown)
Log a system-level error message. The message is logged independently from the logging framework directly to a failsafe logger. If that fails, the message is written directly to the System.err stream.

This method should only be called by other framework providers when they are unsure of whether all the other frameworks have started cleanly, especially property management and startup.

Parameters:
message - The message to log.
thrown - A Throwable, which can be null.

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.