
I solved the ThreadID issue I just didn’t include it in my code and here it is: import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.LayoutBase; public class LayoutTest extends LayoutBase<ILoggingEvent> { public String doLayout(ILoggingEvent event) { StringBuffer sbuf = new StringBuffer(128); long time = event.getTimeStamp() ; sbuf.append(event.getLevel()); sbuf.append(Thread.currentThread().getId()); sbuf.append(" ["); sbuf.append(event.getThreadName()); sbuf.append("] "); sbuf.append(event.getLoggerName()); sbuf.append(" - "); sbuf.append(event.getCallerData()); sbuf.append(CoreConstants.LINE_SEPARATOR); return sbuf.toString(); } } -----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Ceki Gulcu Sent: Wednesday, October 07, 2009 3:21 PM To: logback users list Subject: Re: [logback-user] Feature question Thread id is different than thread name. In the code sample you supplied, you retrieve the thread name and not the thread id. So my question to you is whether you know the difference between therad id and thread name and whether you are interested in thread id or thread name. As for the stack trace, I'll answer that question once the id/name issue is clarified. Ayman Hammoudeh wrote:
I solved the thread id problem by getting the current thread id in my class but my problem now is how to append the exception stack trace from the event object or theres is another way to get the stack trace.
Here is my class again ;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.LayoutBase; public class LayoutTest extends LayoutBase<ILoggingEvent> { public String doLayout(ILoggingEvent event) {
StringBuffer sbuf = new StringBuffer(128); long time = event.getTimeStamp() ;
sbuf.append(event.getTimeStamp() - event.getLoggerContextVO().getBirthTime()); sbuf.append(" "); sbuf.append(event.getLevel()); sbuf.append(" ["); sbuf.append(event.getThreadName()); sbuf.append("] "); sbuf.append(event.getLoggerName()); sbuf.append(" - "); sbuf.append(event.getCallerData());
sbuf.append(CoreConstants.LINE_SEPARATOR);
return sbuf.toString(); } }
-----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Ceki Gulcu Sent: Wednesday, October 07, 2009 2:59 PM To: logback users list Subject: Re: [logback-user] Feature question
From your question, it appears that you are actually not interested in the thread ID but the thread name.
Ayman Hammoudeh wrote:
Yeah thx for the replay that helped me, but I have another question that how can I get the stack trace of an exception if I override the dolayout method and here it is:
package com.logging; import java.sql.Timestamp;
import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.LayoutBase; public class LayoutTest extends LayoutBase<ILoggingEvent> { public String doLayout(ILoggingEvent event) {
StringBuffer sbuf = new StringBuffer(128); long time = event.getTimeStamp() ;
sbuf.append(event.getTimeStamp() - event.getLoggerContextVO().getBirthTime()); sbuf.append(" "); sbuf.append(event.getLevel()); sbuf.append(" ["); sbuf.append(event.getThreadName()); sbuf.append("] "); sbuf.append(event.getLoggerName()); sbuf.append(" - "); sbuf.append(event.getCallerData());
sbuf.append(CoreConstants.LINE_SEPARATOR);
return sbuf.toString(); } }
-----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Joern Huxhorn Sent: Wednesday, October 07, 2009 10:41 AM To: logback users list Subject: Re: [logback-user] Feature question
I think he would like to output thread.getId(). We discussed about this topic here: http://www.qos.ch/pipermail/logback-dev/2009-March/003903.html
Logback isn't able to print the thread-id, at the moment.
Joern.
On 06.10.2009, at 15:54, Ceki Gulcu wrote:
Ayman Hammoudeh wrote:
Hello, Is there a way to get the thread-ID in the layout pattern in xml configuration. Sorry but your question does not make sense or at least I fail to understand it. Anyway, have you looked at the %t or %thread conversion word described at
http://logback.qos.ch/manual/layouts.html#conversionWord ?
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user