[jboss-user] [Beginners Corner] - Re: Logging question (repository selector with local and glo

marcus.klein do-not-reply at jboss.com
Thu Jan 25 09:18:13 EST 2007


Thank you for the answer genman.

In the meanwhile I found another approach. During the initializtaion of the 'local' log4j configuration I check for appender references that doesn't exist within the 'local' log4j file (i.e. which aren't specified by an appender tag). For each such (non existing) appender I check the existing appenders I get by LogManager.getLoggerRepository().getRootLogger() and LogManager.getLoggerRepository().getCurrentLoggers() (one needs to iterate over all possible appenders for each Logger object) in case an appender of the same name can be found it is added to the Logger ('local') that references a non existing appender. Note that the appenders you get from LogManager.getLoggerRepository().XXX() are the ones specified by the 'global' log4j configuration file that is stored in folder JBoss\conf. 
So I am able to reference within my 'local' log4j configuration an appender that is specified within the 'global' log4j configuration file. The disadvantage of this approach is that the appender in the 'global' configuration file must be used (refernced) by at least one logger, since otherwise the appender can't be found.

In case anyone has some suggestions on this approach, they are welcome.

I wonder why it isn't possible, without any additional implementation work, to reference appenders from a 'local' configuration file that are specified within another ('global') configuration file.

The drawbacks I see in the approach that genman suggested are:
- you will need to open another port
- you don't know to which appender the log messages are written, since the default LoggerRepository (LogManager.getLoggerRepository()) is used; or you will need to extend the implementation, so that one can specify which logger/appender from the default LoggerRepository should be used.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4006352#4006352

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4006352



More information about the jboss-user mailing list