<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://83/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Gaston,</div><div><br></div><div>Normally if you need to do something based on the logging level, you'd do.</div><div><br></div><div>if (log.isDebugEnabled()) {</div><div> …</div><div>}</div><div><br></div><div>Is there some special reason why you'd need the exact level?</div><div><br></div><div>David</div><br><div><div>On 30 Jul 2013, at 19:33, gaston sponer <<a href="mailto:gaston.sponer@hotmail.com">gaston.sponer@hotmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div dir="ltr">Hi, Is there any way to get from MyLayout the logger level? I don't want to do this:<div><br></div><div><div>package com.render;</div><div><span style="font-size: 12pt; ">import org.slf4j.LoggerFactory;</span></div><div><span style="font-size: 12pt; ">import ch.qos.logback.classic.Logger;</span></div><div>import ch.qos.logback.classic.spi.ILoggingEvent;</div><div>import ch.qos.logback.core.LayoutBase;</div><div><br></div><div>import com.render.domain.Employee;</div><div><br></div><div>public class MyLayout extends LayoutBase<ILoggingEvent>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">   </span></div><div><span class="Apple-tab-span" style="white-space: pre; ">          </span><b>String level= ((Logger)LoggerFactory.getLogger("employee")).getLevel().toString();</b></div><div>...</div><div>...</div><div><br></div><div>This works well but i don't like to instantiate an object just to get a logger level.</div><div><br></div><div><br></div><div>This is my xml config file:</div><div><br></div><div><div><span style="font-size: 12pt; "><configuration></span></div><div><span style="font-size: 12pt; "><logger name="employee" level="debug"/></span></div><div><span class="Apple-tab-span" style="font-size: 12pt; white-space: pre; ">   </span><span style="font-size: 12pt; "><appender name="CONSOLE" </span><span style="font-size: 12pt; ">class="ch.qos.logback.core.ConsoleAppender"></span></div><div><span class="Apple-tab-span" style="white-space: pre; ">            </span><encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"></div><div>     <span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre; ">            </span><layout class="com.render.MyLayout"  ></div><div>     <span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre; ">            </span></layout></div><div>   <span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre; ">       </span></encoder></div><div>    </appender><span class="Apple-tab-span" style="white-space: pre; ">   </span></div><div><span class="Apple-tab-span" style="white-space: pre; ">  </span></div><div><span class="Apple-tab-span" style="white-space: pre; ">  </span><root level="off"></div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span><appender-ref ref="CONSOLE" /></div><div><span class="Apple-tab-span" style="white-space: pre; ">    </span></root></div><div></configuration></div><div><br></div></div><div><br></div><div>Thanks,</div><div>Gastón.</div><div><br></div></div></div>_______________________________________________<br>Logback-user mailing list<br><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br><a href="http://mailman.qos.ch/mailman/listinfo/logback-user">http://mailman.qos.ch/mailman/listinfo/logback-user</a></div></blockquote></div><br></body></html>