Hi,

I'm a new log4j user. I want to use it in a j2ee web application--however, I want its components, packed in separate jars, to use the same logger(s), if possible.

I've since discovered that if Bar uses a non-static, local, logger, things work as I want. I don't know this is advisable, and shall continue checking.

Thus my new logMessage() is:

private void logMessage(String msg, Level lvl) {
       Logger logger = Logger.getLogger(this.getClass().getName());
       if ( logger.isDebugEnabled()
&& Logger.getRootLogger().getAllAppenders().hasMoreElements() )
           logger.log(lvl, msg);
       else
           System.out.println("sysout:" + msg );
}

The caveat here, I suppose, is that RootLogger will need an appender--even if a do-nothing one. I did read that there are [edge] cases in which the configured-ness of non-root loggers does not bubble up to the root logger. Insight from those who've already been down this path would be much appreciated.

( Incidentally, to elaborate on a prior post, the reason I use logMessage() is because I expect to want to log context information as well, and I'd like NDC push/pop to be isolated to and encapsulated in logMessage )

Regards,

--A

_________________________________________________________________
Don�t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to