logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel.Han...@smed.com
Subject Re: Réf. : %t always returns "main"
Date Fri, 22 Nov 2002 20:49:50 GMT

don't I feel stupid

thanks so much :)

dan




serge.arsenault@desjardins.com on 11/22/2002 03:21:31 PM

Please respond to "Log4J Users List" <log4j-user@jakarta.apache.org>

To:   "Log4J Users List" <log4j-user@jakarta.apache.org>
cc:

Subject:  Réf. : %t always returns "main"



Daniel,
in your main(), shouldn't you do a  "lt.start()" instead of calling
directly "lt.run()"?
Serge Arsenault




Daniel.Hannum@smed.com on 2002-11-22 15:07:12

Veuillez répondre à "Log4J Users List" <log4j-user@jakarta.apache.org>

Pour : "Log4J Users List" <log4j-user@jakarta.apache.org>
cc :
Objet :     %t always returns "main"



Hi. Pardon the stupid question: I can't seem to make the %t (ThreadName)
field work in PatternLayout. It appears to print "main" even if I make the
logging call from a thread with a different name.

Here is my code

// my test logging class
public class PrototypeTest {

  public static void main(String args[]) {
    LogThread lt = new LogThread("My_new_thread");
    lt.run();
  }
}

class LogThread extends Thread {

  LogThread(String name) {
    super(name);
  }

  public void run() {
    DOMConfigurator.configureAndWatch("local.xml", 2000);
    Logger root = Logger.getRootLogger();
    root.error("foo");
  }
}

local.xml is trivial. It attaches a ConsoleAppender to the root, and the
Layout is the default (which contains %t).

Even though I spawned a new thread with the name "My_new_thread", Log4j
says the thread is "main". If I do this.getName() inside run(), it returns
the proper name.

I think if %t just didn't work, people would have noticed, so maybe someone
can point out the flaw in my code.

Thank you

Daniel Hannum




-------------------------------------------------------------------------------

This message and any included attachments are from Siemens Medical
Solutions
Health Services Corporation and are intended only for the addressee(s).
The information contained herein may include trade secrets or privileged or
otherwise confidential information.  Unauthorized review, forwarding,
printing,
copying, distributing, or using such information is strictly prohibited and
may
be unlawful.  If you received this message in error, or have reason to
believe
you are not authorized to receive it, please promptly delete this message
and
notify the sender by e-mail with a copy to CSOffice@smed.com.  Thank you



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










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










-------------------------------------------------------------------------------
This message and any included attachments are from Siemens Medical Solutions 
Health Services Corporation and are intended only for the addressee(s).  
The information contained herein may include trade secrets or privileged or 
otherwise confidential information.  Unauthorized review, forwarding, printing, 
copying, distributing, or using such information is strictly prohibited and may 
be unlawful.  If you received this message in error, or have reason to believe 
you are not authorized to receive it, please promptly delete this message and 
notify the sender by e-mail with a copy to CSOffice@smed.com.  Thank you



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


Mime
View raw message