-
1. Re: Logging question (repository selector with local and glo
genman Jan 24, 2007 8:01 PM (in response to marcus.klein)
I doubt there is an out-of-the-box solution.
One (convoluted) way to make this work would be to have this deployed on the main server:
http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/logging/Log4jSocketServer.java.html
And then configure your per-application appender as a SocketAppender. I assume you know how to create MBeans. -
2. Re: Logging question (repository selector with local and glo
marcus.klein Jan 25, 2007 9:18 AM (in response to marcus.klein)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.