[logback-dev] Small LoggingEvent suggestion

Joern Huxhorn jhuxhorn at googlemail.com
Fri Mar 20 14:44:31 CET 2009


Hi Ceki and sorry for the late reply on this one...

On 04.03.2009, at 18:38, Ceki Gulcu wrote:

> Hello Joern,
>
> The javadocs for getId state:
>
> public long getId()
>
> Returns the identifier of this Thread. The thread ID is a positive  
> long number generated when this thread was created. The thread ID is  
> unique and remains unchanged during its lifetime. When a thread is  
> terminated, this thread ID may be reused.
>
> Thus, the id is not guaranteed to be unique either...

That's true but it is unique, at least, at the time of the  
LoggingEvent creation which would be sufficient I think.

The reason I'm asking this is that I'm looking into import of various  
logging events into Lilith and I had to realize that jul is sending  
*only* the thread id, *not* the name of the thread - which is pretty  
pointless if you ask me.

Therefore I saw the requirement to support more than just the name to  
be able to import jul events lossless concerning the contained info.

I created a ThreadInfo class that contains the following:

threadName
threadId
threadGroupName
threadGroupId (this is System.identityHashCode(threadGroup) since  
there is no such thing as a ThreadGroup id)

All of those are optional.
In case of current logback-classic only threadName is filled in, in  
case of jul only threadId.

At the moment, my LogbackLoggingAdapter is filling in the additional  
info itself which means that you'll get all of the above if you use my  
appender. I think it's worthy additional data.

btw, I also realized that jul is only sending the root throwable and  
no causes. This is *the* most unusable Java API, imo.

Just for the record: Did they contact you when they were developing  
it? I mean log4j was well established at that point...

Joern.

>
>
> Joern Huxhorn wrote:
>> Hi all,
>> I'd like to suggest to include thread id (in addition to the name) in
>> LoggingEvent.
>> I'd use a Long as the data type instead of long so it's possible to
>> distinguish if it was initialized or not.
>> The name alone isn't guaranteed to be unique so the id wouldn't  
>> hurt, imho.
>> Joern.
>
> -- 
> Ceki Gülcü
> Logback: The reliable, generic, fast and flexible logging framework  
> for Java.
> http://logback.qos.ch
> _______________________________________________
> logback-dev mailing list
> logback-dev at qos.ch
> http://qos.ch/mailman/listinfo/logback-dev



More information about the logback-dev mailing list