<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> i'm working with Logback and i'm sending this concern to you<br>because i can't find any solution for my problem.<br>What i need to know if i can manipulate my objects in the layouts.<br><br>Ex.:<br>------------------------------<u></u><wbr>------------------------------<u></u><wbr>--------------------<br>public RenderTest class{<br><br>static final Logger logger = LoggerFactory.getLogger("Fred"<u></u><wbr>);<br>public static void main(String...args){<br>getRenderTest().logging();<br>}<br>static RenderTest getRenderTest(){<br>   return new RenderTest();<br>}<br><br>private void logging(){<br>xmlFileConfiguration();<br>Employee employee = getSampleEmployee();<br>logger.debug("Employee {}", new EmployeeRenderer().<u></u>getLogMessa<wbr>ge(employee, logger));<br>}<br>private Employee getSampleEmployee(){</blockquote><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br>  Person person = new Person("John", 36, 3124362);<br>  Address address =  new Address("Columbus", 756, "Cordoba", "X5003","Cordoba");<br>  Salary salary = new Salary(18565.54, "ARS");<br>  Employee employee = new Employee("AA", 324214231, salary, person,address);<br>  return employee;<br>  }<br>}<br>------------------------------<u></u><wbr>------------------------------<u></u><wbr>--------------------<br>MyLayout:<br><br>public class EmployeeLayout extends LayoutBase<ILoggingEvent>{</blockquote><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br>Context logger = getContext();<br><br></blockquote><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">  public String doLayout(ILoggingEvent event) {<br>    StringBuffer sbuf = new StringBuffer(128);<br>    sbuf.append(event.getLevel());<br>    sbuf.append(" [");<br>    sbuf.append(event.<u></u>getThreadNam<wbr>e());</blockquote><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">//    sbuf.append(employee.getName());  // How can i get employee object from here?<br>    sbuf.append("] ");</blockquote><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">    sbuf.append(event.<u></u>getLoggerNam<wbr>e());<br>    sbuf.append(" - ");<br>    sbuf.append(event.<u></u>getFormatted<wbr>Message());<br><br></blockquote><blockquote class="gmail_quote" style="font-family: arial, sans-serif; font-size: 13px; margin-right: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">    //so far so good, but now I need to get my employee object to render some important information from it.<br>    // I tried with event.getArgumentArray()[0], but I can't take for instance a employee.getCompany()<br><br>    return sbuf.toString();<br>  }<br><br>}<br>------------------------------<u></u><wbr>------------------------------<u></u><wbr>--------------------<br>My config file:<br><configuration><br><logger name="Fred" level="debug"/><br><br> <appender name="CONSOLE" class="ch.qos.logback.core.<u></u>Con<wbr>soleAppender"><br>  <encoder class="ch.qos.logback.core.<u></u>enc<wbr>oder.LayoutWrappingEncoder"<u></u>><br>     <layout class="com.render.<u></u>EmployeeLayo<wbr>ut" /><br>  </encoder> --><br></appender><br><root level="off"><br><appender-ref ref="CONSOLE" /><br></root><br></configuration><br><br>------------------------------<u></u><wbr>------------------------------<u></u><wbr>--------------------<br><br>I would like to do something like this from layout to decide what objects will show in the log:<br><br>  sbuf.append(employee.getName()<u></u><wbr>);<br>  sbuf.append(employee.<u></u>getCompan<wbr>y());<br><br>Is there any way to do that? Do you see any drawbacks to do that?<br><br>Thanks a lot,<br><br></blockquote><div><br></div>                                       </div></body>
</html>