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/17 18:50:13 UTC

log objects and use the values separately in the appenders with conversion pattern

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