There is no java API to access the server log, however you can invoke the debugLog service from within your java code.
Here is an example method that could be used as part of log4j as a ServerLogAppender class.
public void logToServerLog(LoggingEvent event) {
// Bug in wm, means that if we try to invoke services outside of service-pool we get a null pointer
// exception. Following if fixes the problem by ensuring we have session and uses assigned.
if (event.getLevel().toInt() == Level.ERROR_INT || event.getLevel().toInt() == Level.FATAL_INT)
{
if (event.getThrowableInformation() != null && event.getThrowableInformation().getThrowable() != null)
ServerAPI.logError(event.getThrowableInformation().getThrowable());
}
IData input = IDataFactory.create();
IDataCursor inputCursor = input.getCursor();
IDataUtil.put(inputCursor, "message", event.getMessage());
IDataUtil.put(inputCursor, "function", event.getLoggerName());
IDataUtil.put(inputCursor, "level", "0");
inputCursor.destroy();
try {
ServiceUtils.invokeService(input, "pub.flow", "debugLog", null, null, true); // don't use session causes null pointer exception in certain cases
} catch( Exception e) {
e.printStackTrace();
ServerAPI.logError(new ServiceException ("Couldn't log debug info to server log : " + e));
}
}
#Integration-Server-and-ESB#webMethods-io-Integration#webMethods