[logback-user] Logger level from Layout class

gaston sponer gaston.sponer at hotmail.com
Tue Jul 30 20:33:32 CEST 2013


Hi, Is there any way to get from MyLayout the logger level? I don't want to do this:
package com.render;import org.slf4j.LoggerFactory;import ch.qos.logback.classic.Logger;import ch.qos.logback.classic.spi.ILoggingEvent;import ch.qos.logback.core.LayoutBase;
import com.render.domain.Employee;
public class MyLayout extends LayoutBase<ILoggingEvent>{			String level= ((Logger)LoggerFactory.getLogger("employee")).getLevel().toString();......
This works well but i don't like to instantiate an object just to get a logger level.

This is my xml config file:
<configuration><logger name="employee" level="debug"/>	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">      		<layout class="com.render.MyLayout"  >      		</layout>    	</encoder>    </appender>			<root level="off">		<appender-ref ref="CONSOLE" />	</root></configuration>

Thanks,Gastón.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130730/e9b8c723/attachment.html>


More information about the Logback-user mailing list