The SBLIM CIM Client for Java has a log & trace API that is extensible by application. Since the cim client is always running in the context of an application it is not desired that it writes it's own log files. Therefore the SBLIM CIM Client for Java offer listener interfaces for log & trace messages to which application can subscribe and forward the messages to the application's logger.
We destinguish between log & trace. The audience of the log is an admin at the customer site. The log is localized and contains only the most important messages. The messages are listed in a catalog. The audience of the trace are service engineers and support people. It is not localized, but always in english and may contain the most detailed trace messages at wish. The trace is always a superset of the log, means all messages send to the log are send to the trace as well.
The trace is a tool for problem determination that shouldn't be active in normal operation. Tracing at levels of FINE and below creates much more messages than logging. Moreover for every entry in the trace file the stack trace is analyzed to identify the originating method. Having full tracing active therefore will degrade performance.
The message levels are taken from java.util.logging.Level
(descreasing severity):
All messages with a Level<CONFIG will be send to the trace only.
An application can register itself as a listener for log and/or trace messages. In order to do so it must implement
the LogListener
and/or TraceListener
interfaces and call
addLogListener()
/
addTraceListener()
on the LogAndTraceManager
instance.
The following code snippet gives an example:
LogAndTraceManager manager = LogAndTraceManager.getManager(); manager.addLogListener(new LogListener() { public void log(Level pLevel, String pMessageKey, String pMessage, Object[] pParameters) { System.out.println("Log message "+pMessageKey+" (Level="+pLevel+"): " +MessageFormat.format(pMessage, pParameters)); } }); manager.addTraceListener(new TraceListener() { public void trace(Level pLevel, StackTraceElement pOrigin, String pMessage) { System.out.println("Trace message (Level="+pLevel+") from " +String.valueOf(pOrigin)+": "+pMessage); } public void trace(Level pLevel, StackTraceElement pOrigin, String pMessage, Throwable pThrown) { System.out.println("Trace message (Level="+pLevel+") from " +String.valueOf(pOrigin)+": "+pMessage); pThrown.printStackTrace(); } });
The System.out.println()
would of course be replaced with the API calls of the applications logger
You say: "That's interesting stuff, but I just want my plain old log files back." No problem, the SBLIM
CIM Client for Java offers this as well. Via our configuration properties you can set up classical file logging out of
the box. See our configuration document for details on how to set configuration properties.
The sblim-cim-client2.properties
file contains documentation on all properties.
Note: If you want to setup the logging via System.setProperty()
calls, make sure that this happens before
any CIM client class is loaded by the classloader. The classic logging is set up in static initializers.