Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Thread-based Logging with log4j

Thread view: 
brian.vanheesch@gmail.com - 18 May 2006 12:47 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.
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.