At 11:46 AM 4/5/2004 +0200, you wrote:
Hi,

Is it possible to set configuration so log4j logs current thread's hashcode
instead of thread's name?
My server sets names of all threads to "ApplicationServerThread" :-) and I
can not tell
which thread is handling which user. "Signing" each log entry with thread
hashCode seems like not
difficult tasks would really help me.

See my comments on PatternLayout below.


Actually I have already implemented a "proxy" around Logger that adds
hashcode to printed message,
but the problem is that logged line numbers are always line numbers of the
"proxy" class. Interesting -
the class name is the name of the class that invokes debug() on "proxy"
class - so with class name
there is no problem.

I have checked method getLineNumber() in LocationInfo. and now it looks to
me really difficult to "fix"
the problem with line numbers.

Actually support for wrappers is provided through the generic


<../../../org/apache/log4j/Category.htm#log(java.lang.String, org.apache.log4j.Priority, java.lang.Object, java.lang.Throwable)>log(String callerFQCN, <../../../org/apache/log4j/Priority.htm>Priority level, Object message, Throwable t)

method.

I was also thinking about using NDC. In a servlet it would work but in EJB
it looks that I would have
to set NDC each time a method is invoked (am I correct here? ) Since there
is several thousands
methods in my project it is simply too much work.

You could set the NDC or MDC in a servlet filter or EJB interceptor.


Or maybe is it possible to define my own "letter" in Converter that would
map to my class and in this class
I just can generate String with current thread's hashcode and it will be
appended to log entry?

Support for this provided in PatternLayout in log4j v 1.3. See http://qos.ch/logging/PatternLayout.html for more details.

I hope this helps,

Regards,

Michal Olek

-- Ceki G�lc�

For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to