You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Brendan D. Reekie" <BD...@rsssolutions.com> on 2004/06/23 16:37:35 UTC

Layout that includes the name of the application

I've perused through the online documents and FAQ's and haven't found a
way if it's possible to include the name of the class that the JVM
executed (the main class).

 

For example if class Foo has the main() method and calls into class Bar
that contains a logging message.  Is it possible to include Foo in the
layout of the logging message?  I've tried combinations of %C or %F but
it only reports Bar.  

 

This would be useful primary from our unittest perspective of
understanding what unittest was running that triggered off the log
messages.

 

Thanks in advance,

 

 Brendan Reekie

RSS Solutions Inc.

77 Wellington Street South,

Kitchener, ON.

N2G 2E6

Voice:      (519) 746-7200 x 239                             

                1-888-330-7314 x 239

Fax:         (519) 746-8727

Email:       bdr@rsssolutions.com <ma...@rsssolutions.com>  

 


Re: Layout that includes the name of the application

Posted by Larry Young <ly...@dalmatian.com>.
Brendan,

         Well, one quick way I can think of would be to define an MDC value 
in your main() method and then add that to your pattern layout specification.

--- regards ---
Larry


At 07:37 AM 6/23/04, you wrote:
>I've perused through the online documents and FAQ's and haven't found a 
>way if it's possible to include the name of the class that the JVM 
>executed (the main class).
>
>For example if class Foo has the main() method and calls into class Bar 
>that contains a logging message.  Is it possible to include Foo in the 
>layout of the logging message?  I've tried combinations of %C or %F but it 
>only reports Bar.
>
>This would be useful primary from our unittest perspective of 
>understanding what unittest was running that triggered off the log messages.
>
>Thanks in advance,
>
>[]
>Brendan Reekie
>RSS Solutions Inc.
>77 Wellington Street South,
>Kitchener, ON.
>N2G 2E6
>Voice:      (519) 746-7200 x 239
>                 1-888-330-7314 x 239
>Fax:         (519) 746-8727
>Email:       <ma...@rsssolutions.com>bdr@rsssolutions.com
>

--------------------------
Larry Young
The Dalmatian Group
www.dalmatian.com 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org