Issue Type: Improvement Improvement
Affects Versions: 1.0.13
Assignee: Logback dev list
Components: logback-classic
Created: 30/May/13 7:07 AM
Description:

Profiling our application with following logback configuration showed that message in LoggingEvent is constructed even if it will not be logged. Is it possible to make it computed lazily?

Excerpt from out logback.xml:

<appender name="DEBUG"
	class="ch.qos.logback.core.rolling.RollingFileAppender">
	<File>debug.log</File>
	<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
		<FileNamePattern><![CDATA[debug.%i.log]]></FileNamePattern>
		<minIndex>1</minIndex>
		<maxIndex>5</maxIndex>
	</rollingPolicy>

	<triggeringPolicy
		class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
		<maxFileSize>30MB</maxFileSize>
	</triggeringPolicy>

	<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
		<level>DEBUG</level>
	</filter>

	<encoder>
		<Pattern><![CDATA[%date{YYYYMMdd HH:mm:ss.SSS} [%thread][%-5level][%X{tenantId}] %-50logger{50}:%line - %message%n]]></Pattern>
		<charset>UTF-8</charset>
		<immediateFlush>false</immediateFlush>
	</encoder>
</appender>

<appender name="TRACE"
	class="ch.qos.logback.core.rolling.RollingFileAppender">
	<File>trace.log</File>
	<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
		<FileNamePattern><![CDATA[trace.%i.log]]></FileNamePattern>
		<minIndex>1</minIndex>
		<maxIndex>5</maxIndex>
	</rollingPolicy>

	<triggeringPolicy
		class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
		<maxFileSize>30MB</maxFileSize>
	</triggeringPolicy>

	<encoder>
		<Pattern><![CDATA[%date{YYYYMMdd HH:mm:ss.SSS} [%thread][%-5level][%X{tenantId}] %-50logger{50}:%line - %message%n]]></Pattern>
		<charset>UTF-8</charset>
		<immediateFlush>false</immediateFlush>
	</encoder>
</appender>

<logger name="com.our_package">
	<!-- TRACE does not mean that it will be printed.
	we just not filter it on logger level,
	but messages will filtered later on appenders level -->
	<level value="trace" /> 
</logger>

<root>
	<level value="info" />
	<appender-ref ref="MAIN" />
	<appender-ref ref="ERROR" />
<!-- debug log not enabled by default. Uncomment if needed. Use it wisely! -->
	<!--appender-ref ref="DEBUG" /-->
<!-- trace log not enabled by default. Uncomment if needed. Use it wisely! -->
	<!--appender-ref ref="TRACE" /-->
</root>

What is happening: Logger is set to trace so it passes everything, event is formatted, event is discarded by ThresholdFilter.

The idea for this configuration is to have several log files with different detalization. I think this is a valid usecase.

Project: logback
Priority: Major Major
Reporter: Mikhail Mazursky
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to