On Aug 17, 2005, at 1:17 AM, Adam Megacz wrote:
Assuming that log4j is up and running in some unknown state, is there any way to programmatically intercept all log messages and "do something" with them?
With Bender Hari's suggestion I believe you would be limited to only capturing the message part of the logging request and would lose time- stamp, logger name, NDC, MDC and the like. You would also see only those logging requests that passed the threshold tests to get into the dispatching pipeline. If, for example, you wanted to see all logging requests even though log4j was configured to turn logging off, the approach would not work since the logging requests would never get into the dispatching pipeline.
Most of the log4j docs seem oriented towards static configuration (properties files) rather than dynamic configuration.
The documentation is oriented that way since that is the more common way to use log4j. However, the configurators use public methods that any app can call to configure log4j and the configuration can be changed during the application lifetime.
The way you phrased the question appears that you want to countermand or veto an explicit configuration decision made earlier. log4j doesn't make it easy for you to fight or override an earlier configuration (you can however reset it and start again). When and how log4j is configured is controlled by the calling application, so you should make your life easier by controlling how log4j is configured.
If you give more details of the situation that you are facing, maybe we can give you better advice.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
