Hi,
Only threads that do not set their name themselves have a thread number. So your suggestion does not always work. At 21:39 01.04.2002 +0200, you wrote: >Hi > >Please add a method String getThreadNumber() to the class >org.apache.log4j.spi.LoggingEvent which >returns the thread number only, i.e. without the (pretty much redundant) text >"Thread-" in front. > >I am aware that this is some awkward reverse engineering. It would be >better if >the thread implementation itself in the Java library would provide such a >function - is anybody aware of a change request to Sun about that? > >Here's a code snippet that would do this: > > public > String getThreadNumber() { > if(threadNumber == null) { > String s = (Thread.currentThread()).getName(); > if ("main".compareTo(s) == 0) > threadNumber = "m"; > else > threadNumber = s.substring(7); > } > return threadNumber; > } > > >-Bernd. > > >-- >Bernd Goetz [EMAIL PROTECTED] >TARSEC AG Tel +41 1 496 61 11 >Rautistrasse 12 Fax +41 1 496 61 99 >Postfach Mobile +41 79 759 04 26 >8047 Zurich, Switzerland http://www.tarsec.com >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- Ceki My link of the month: http://www.suntimes.com/output/otherviews/cst-edt-ref31.html -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>