Now what I am thinking of doing is to 1. create a class which is an appender that intercepts the messsages and writes it to a StringWriter with which it is initialized.
This would work, but I always just added the logging Event to an internal List, and converted them all to whatever I needed later on. This defers the cost until you actually need it (if you do).
2. at the beginning of the routine that handles a request, I create a new appender and initialize it with the stringwriter. It appends to the stringwriter any messages that it gets.
I assume by this that you mean that you add this new appender to the appropriate Logger that you are interested.?
3. at the end of the routine request handling routine, I get the stringwriter from the appender and destroy it in a finally clause.
You could do this destruction code in the appenders .close() method, which would be the standard practice. Don't forget to _remove_ the appender from the logger as well.
4. In the logging properties file I would add this appender as well ( I am not sure if this is necessary since I create this appender manually ?)
No need to do this, you would just be doubling up.
Any other comments/thoughts. btw, I remember thinking about using ThreadLocal but dont see it relevant
I think it still is relevant here, as you could have 2 or more threads actively executing in the same routine, both adding appenders to the logger, and BOTH adding event details to the other appenders. I'm not sure that's what you want.
While you might not need to use a ThreadLocal, you COULD initialise each appender that is created and added to the Logger with a Filter that will only accept LoggingEvents from the currentThread. That way multiple threads could add their own logger and know that they will not interfear with one another.
Hope that makes sense.
cheers,
Paul Smith
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]