I was wondering if there is a way to do the following that may or may not be possible.
I have a bunch of code that is already using log4j right now. The loggers that are used to log messages are your standard logfactor.getlog ( ClassName.class). I would like to capture all the logging messages for a given unit of work into a new appender that is set up at runtime. I would like all the code that runs after setting up this appender to send log messages to this new appender as well as the pre-existing configured appenders, and I imagine the way to do this is via ThreadId. Something like this 1. Setup a new appender 2. Somehow insert the appender into the log4j configuration tied to the current threadID 3. call a bunch of old code that is already using log4j, all the log messages are caught by the existing configured appenders in addition to my new appender 4. return from calling code 5. Shutdown the new appender and remove it from the existing log4j configuration. So I am asking if its possible to insert an appender such that subsequent log messages for a certain threadID go to that appender, and then remove that appender after code has run. I will be looking at the docs and code for log4j but thought I would ask to see if anyone has done anything like this. Thanks Will