|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.logging.LoggingProvider
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.
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 |
public static LoggingProvider getProvider()
public static void resetProvider()
public LoggingCategory getCategory(String name)
name
.
name
- The name of the logging category to retrieve.
public void configure()
public void logSystemError(String message, Throwable thrown)
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.
message
- The message to log.thrown
- A Throwable
, which can be null
.
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |