I am trying to setup a custom appender that will log thread specific
messages to seperate log file (customer-requirement).
Is something like this possible? Any ideas would be helpful.
Robert Klemme - 18 May 2006 13:38 GMT
> I am trying to setup a custom appender that will log thread specific
> messages to seperate log file (customer-requirement).
>
> Is something like this possible? Any ideas would be helpful.
I'd guess so (never did it myself but the framework is quite flexible).
Personally I'd prefer just writing the thread id to the log file (this
can be done).
robert
dimitar - 18 May 2006 16:08 GMT
I believe that if you have just a few threads that you want to separate,
you can use Log4J filters for this. You can set them from XML config
file or directly from the code (no way to do it using properties).
Otherwise, your only choice is to use a thread-local Logger+Appender
instance which gets created and configured in your code when you start
the thread. Make sure that you remove the logger from the
LoggerHierarchy when the thread exits.
An excellent resource for log4j is the Ceki Gulcu's book
(https://www.qos.ch/shop/products/list.jsp).
cheers,
Dimitar