logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: Feature request: add support to remove "Thread-" from thread id
Date Tue, 02 Apr 2002 08:38:43 GMT

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                                     goetz@tarsec.com
>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:log4j-dev-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>

--
Ceki
My link of the month: 
http://www.suntimes.com/output/otherviews/cst-edt-ref31.html


--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message