I'm trying to figure out how to write a custom LogFormatter that is able to include the name of the thread that generates a LogRecord. It's very simple to get the thread ID through LogRecord.getThreadID() - but the problem is that the implementation for this API method actually creates a ThreadLocal that maintains an "ID" that has absolutely nothing to do with the VM's thread ID.
I looked into using the java.lang.management APIs - specifically ThreadMXBean and ThreadInfo, which allows one to easily lookup a thread's name based on its ID. However, since this thread ID is completely unrelated to the thread ID reported in a LogRecord, it is not easy to match up the actual name of the thread that generated the LogRecord with the ID contained within the LogRecord.
BTW, I am using Java 5.0 Update 7, though I don't necessarily have an objection to upgrading to a beta of Mustang, if necessary...
Does anyone have any suggestions on how to accomplish this?