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 Joerg Eggink <fa...@gmx.de> on 2005/01/18 11:55:57 UTC

Re: log objects and use the values separately in the appenders wi th conversion pattern

Hello Dirk

Thank you very much. That is exacly what I need.

Best Regards

Joerg



OOMS DIRK wrote:

>You could map the 3 strings onto MDC key-value pairs, e.g. (m1, "string1)
>and address them in a PatternLayout by %X{m1}, etc.
>
>Hope this is what you were looking for.
>
>dirk
>
>  
>
>>Dear All
>>
>>Is it possible to log for example a object with 3 strings and 
>>refer it 
>>later in PatternLayout with e.g %m1 %m2 %m3 ?
>>
>>Below there is some dummy code.
>>
>>Thanks in advance for any hint.
>>
>>Best Regards
>>
>>Joerg
>>
>>
>>
>>Example dummy code:
>>
>>----------------------
>>class MESSAGE{
>>
>>public String a;
>>public String b;
>>public String c;
>>
>>public message (String a, String b, String c)
>>{
>>this.a = a;
>>this.b = b;
>>this.c = c;
>>}
>>
>>}
>>-----------------
>>
>>somewhere in the program
>>....
>>MESSAGE message new MESSAGE ("hello", "log", "reader");
>>....
>>logger.getLogger(CategoryName).log(WRAPPER_FQN, Level.INFO, 
>>message,null);
>>....
>>----------------
>>in the log4j.xml
>>  <appender ...>
>>    <layout class="org.apache.log4j.PatternLayout">
>>      <param name="ConversionPattern"
>>       value="%m1 %m2 %m3)" />
>>   </layout>
>>....
>>
>>----------------
>>As output from the appender
>>hello log reader
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>  
>



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