- priority: 5 --> 7
It would be nice to integrate the logging output in existing log files using a commons logging Log instance.
The current possibility to switch the LogWriter is not enough since it is given only the prepared log message string from the KeLog instance.
It would be nice to provide the possibility to map priority and classname of the originating class to priorities and categories of the Commons-Logging API.
To utilize the Commons-Logging API, following information from the originating call to KeLog is needed in some LogAdapter interface:
- Priority
- Class Name
- Exception, if any
- the message itself, maybe enriched with additional information from the WidgetServer framework
This data may be used to create or fetch a Commons-Logging Log instance and log the message to it:
public void pcmf_log(String message, int priority, String classname, Throwable t) {
Log commonsLoggingLogger = LogFactory.getLog(classname);
switch (priority) {
case (KeLog.SILENT):
// log nothing
break;
case (KeLog.TRACE):
if (t != null) {
commonsLoggingLogger.trace(message, t);
} else {
commonsLoggingLogger.trace(message);
}
break;
case (KeLog.DEBUG):
if (t != null) {
commonsLoggingLogger.debug(message, t);
} else {
commonsLoggingLogger.debug(message);
}
break;
case (KeLog.APPL):
case (KeLog.MESSAGE):
if (t != null) {
commonsLoggingLogger.info(message, t);
} else {
commonsLoggingLogger.info(message);
}
break;
case (KeLog.ERROR):
if (t != null) {
commonsLoggingLogger.error(message, t);
} else {
commonsLoggingLogger.error(message);
}
break;
case (KeLog.FATAL):
if (t != null) {
commonsLoggingLogger.fatal(message, t);
} else {
commonsLoggingLogger.fatal(message);
}
break;
}
}
This way the existing logging infrastructure used in complex enterprise applications may be utilized by the WidgetServer web module as well.
Log in to post a comment.