
Hello Richard, Here is the logback-classic equivalent of the AgentLogger you posted. import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; public final class AgentLogger { // LoggerContext replaces log4j's Hierarchy public static LoggerContext context = new LoggerContext(); // set the root logger's level to TRACE static { Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.TRACE); } private Logger wl = null; private AgentLogger(String name) { wl = context.getLogger(name); wl.setAdditive(false); } } HTH, -- Ceki On 06/06/2011 11:37 PM, Richard Sand wrote:
Hi all,
I’m working with a COTS application, writing some extensions for it. The application has a proprietary logging API. In the past, I wrote a custom logging class wrapping log4j to bridge to the COTS application’s log capability. To totally isolate the usage of log4j in the API I created a wrapper around a Logger with its own Hierarchy.
We’re now exploring replacing log4j with logback in these extensions and I’m wondering if there is an analogous mechanism for accomplishing this in logback.
Here is an example of what I’m doing with log4j. Note how I create a new Hierarchy and then create a logger from that hierarchy with additivity turned off. How would I do this with logback?
*public**final**class*AgentLogger {
*public**static*Hierarchy /heirarchy/= *new*Hierarchy(*new*RootLogger(Level./TRACE/));
*private*Logger wl= *null*;
/**
* Private constructor
*
* *@param*name
*/
*private*AgentLogger (String name) {
wl= /heirarchy/.getLogger(name);
wl.setAdditivity(*false*);
}
Any advice appreciated. Thanks!
Best regards,