

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
14 messages in org.apache.logging.log4j-userRe: Fw: ThreadLocalAppender for log4j...| From | Sent On | Attachments |
|---|---|---|
| Ramakrishna Menon | Mar 1, 2004 5:25 pm | |
| Ceki Gülcü | Mar 2, 2004 2:18 am | |
| Ramakrishna Menon | Mar 2, 2004 7:26 am | |
| Ceki Gülcü | Mar 2, 2004 8:13 am | |
| Paul Smith | Mar 2, 2004 11:56 am | |
| Ramakrishna Menon | Mar 2, 2004 12:12 pm | |
| Paul Smith | Mar 2, 2004 1:22 pm | |
| Ramakrishna Menon | Mar 2, 2004 3:33 pm | |
| Paul Smith | Mar 2, 2004 3:42 pm | |
| Ramakrishna Menon | Mar 2, 2004 4:36 pm | |
| Ramakrishna Menon | Jun 23, 2004 9:11 am | |
| Ramakrishna Menon | Jun 25, 2004 9:44 am | |
| Paul Smith | Jun 27, 2004 2:53 pm | |
| Ramakrishna Menon | Jun 28, 2004 8:39 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: Fw: ThreadLocalAppender for log4j?resending | Actions... |
|---|---|---|
| From: | Ramakrishna Menon (rama...@oracle.com) | |
| Date: | Jun 28, 2004 8:39:51 am | |
| List: | org.apache.logging.log4j-user | |
Thank you Paul! I will digest, implement and get back asap:) Best Regards, Menon:) ------------------------------------------------------------- Ramakrishna M. Menon (A Rafi Fan - http://www.mohdrafi.com ) MBA, Berkeley Oracle Corp.-> (650) 506-2343 http://websites.oraclecorp.com/websites/pub/oracleperformance/ -------------------------------------------------------------
----- Original Message ----- From: "Paul Smith" <psm...@apache.org> To: "Log4J Users List" <log4...@logging.apache.org> Sent: Sunday, June 27, 2004 2:53 PM Subject: Re: Fw: ThreadLocalAppender for log4j?resending
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







