|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openmdx.kernel.log.PluggableLoggingMechanism
public abstract class PluggableLoggingMechanism
This PluggableLoggingMechanism mechanism implements a base class
for pluggable mechanisms.
Pluggable mechanism implementations:
The logging framework is designed not to rely on dynamic classloading to
prevent any problems with the wide range of application architecture
frameworks (Corba, J2EE, ...). Therefore the applications must
itself instantiate their pluggable mechanisms and attach /
detach them with the log framework.
A sample Pluggable Logging Mechanism
public class ObserverMechanism extends PluggableLoggingMechanism
{
public ObserverMechanism() {}
public String getMechanismName() { return "ObserverMechanism"; }
public void log(LogEvent event)
{
if (event.getLoggingLevel() == LogLevel.LOG_LEVEL_CRITICAL_ERROR) {
System.out.println("*************************************");
System.out.println("* OBSERVER: CRITICAL ERROR");
System.out.println("* Class : " + event.getClassName());
System.out.println("* Method : " + event.getMethodName());
System.out.println("* Summary : " + event.getLogStringSummary());
System.out.println("* Detail : " + event.getLogStringDetail());
System.out.println("*************************************");
} //if
}
};
public class Sample
{
public static void main (String[] args)
{
// initialize the logging subsystem
AppLog.setConfigName("Sample");
AppLog.setLogSource("MySample");
// Read the observer's log property
String observerMyProperty = SysLog.getLogConfig().getLogProperty(
"ObserverMechanism.myProperty", "")
// instantiate your pluggable logging mechanism
ObserverMechanism observer = new ObserverMechanism();
// Make it available to the log subsystem
observer.attach(AppLog.getLogConfig());
observer.activate();
... YOUR IMPLEMENTATION ...
// Release it from the log subsystem (optional)
observer.deactivate();
observer.detach();
}
}
The log property file Sample.log.properties could look as follows:
LogFileExtension = log
LogFilePath =
LogLevel = 3
java.LoggingMechanism = StandardErrorLoggingMechanism
java.LoggingMechanism2 = ObserverMechanism
LogPerformance = true
LogNotification = false
SysLog.ObserverMechanism.myProperty = demo
| Constructor Summary | |
|---|---|
protected |
PluggableLoggingMechanism()
|
| Method Summary | |
|---|---|
boolean |
acceptsPerformance()
Checks if the mechanisms accepts performance logs. |
boolean |
acceptsStandard()
Checks if the mechanisms accepts standard logs. |
boolean |
acceptsStatistics()
Checks if the mechanisms accepts statistics logs. |
boolean |
activate()
Activates the logging mechanism. |
boolean |
attach(Config loggerConfig)
Attach the logging mechanism to the logging framework. |
boolean |
attach(Config[] loggerConfigs)
Attach the logging mechanism to the logging framework. |
boolean |
deactivate()
Deactivates the logging mechanism. |
boolean |
detach()
Detach the logging mechanism from the logging framework |
String |
getMechanismName()
Return the name of the mechanism. |
boolean |
isActive()
Checks if the mechanism is open |
boolean |
isAttached()
Checks if the mechanism is attached to the logging framework |
void |
log(LogEvent event)
Logs an event. |
void |
notifyLoggingLevelChange(int newLoggingLevel)
This method is called, to inform the pluggable logging mechanism that the log level has changed. |
void |
notifyLoggingPerformanceChange(boolean newState)
This method is called, to inform the pluggable logging mechanism that the log performance has changed. |
void |
notifyLoggingStatisticsChange(boolean newState)
This method is called, to inform the pluggable logging mechanism that the log statistics has changed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected PluggableLoggingMechanism()
| Method Detail |
|---|
public void log(LogEvent event)
IMPORTANT: The pluggable logging mechanism only gets log events that conform the actual logging level.
event - A log eventpublic String getMechanismName()
public void notifyLoggingLevelChange(int newLoggingLevel)
loggingLevel - A logging levelpublic void notifyLoggingPerformanceChange(boolean newState)
newState - A new performance statepublic void notifyLoggingStatisticsChange(boolean newState)
newState - A new performance statepublic boolean acceptsStandard()
public boolean acceptsStatistics()
public boolean acceptsPerformance()
public final boolean attach(Config[] loggerConfigs)
activate() to activate the mechanism.
loggerConfigs - An array of loggers (AppLog, SysLog, ...) to
attach the mechanism to.
public final boolean attach(Config loggerConfig)
activate() to activate the mechanism.
loggerConfig - A logger (AppLog, SysLog, ...) to
attach the mechanism to.
public final boolean detach()
public final boolean activate()
public final boolean deactivate()
public final boolean isAttached()
public final boolean isActive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||