Ceki Gülcü <listid <at> qos.ch> writes:

> 
> Hi Mark,
> 
> I don't see how implementing o.a.c.logging.Log and LogFactory with log4j 
> helps around this problem. How do you avoid keeping a map of JCL adapters 
> wrapping log4j loggers? If you don't keep a map, how do you avoid building 
> a new JCL adapter object each time the LogFactory.getFactory gets called?
> 
> Does the above make sense?
> 

Hi Ceki,

In my custom MyFrameworkLogFactory.getInstance(String name) method I do the
following:

Context ctx = null;
String loggingContextName = null;
String fullName = null;
try {
        ctx = JNDIUtil.getInitialContext();
        loggingContextName = (String) JNDIUtil.lookup(ctx, 
Constants.JNDI_CONTEXT_NAME);
} catch (NamingException ne) {
        // we can't log here
        ne.printStackTrace();
}

fullName = loggingContextName + "-" + name;

synchronized (this) {
        instance = (Log) loggerMap.get(fullName);
        if (instance == null) {
                Logger logger = Logger.getLogger(name);
                instance = new HpLog(logger);
                loggerMap.put(fullName, instance);
        }
}
return instance;

Is that wrong or inefficient?

_______________________________________________
user mailing list
[email protected]
http://www.slf4j.org/mailman/listinfo/user

Reply via email to