<?xml version="1.0" encoding="UTF-8"?>

<configuration>

	<!-- Stop logback initialization blathering at startup -->
	<statusListener class="ch.qos.logback.core.status.NopStatusListener" />

	<!-- logdir value can be set to a static directory path or to ${TMP_DIR} -->
	<!-- ${TMP_DIR} is a temporary directory computed by bin/lsc and transmitted as a java system property -->
	<property name="logdir" value="${TMP_DIR}" />

	<!-- Standard output to console -->
	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
			<layout class="org.lsc.utils.output.LdifLayout">
				<Pattern>%date{MMM dd HH:mm:ss} - %-5level - %message%n</Pattern>
			</layout>
		</encoder>
	</appender>

	<!-- Log all application messages -->
	<!-- this file is rotated every 10000KB, compressed and 7 files are kept for history -->
	<appender name="LSC" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${logdir}/lsc.log</file>

		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
			<layout class="org.lsc.utils.output.LdifLayout">
				<Pattern>%date{MMM dd HH:mm:ss} - %-5level - %message%n</Pattern>
			</layout>
		</encoder>

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

		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
			<FileNamePattern>${logdir}/lsc.log.%i.gz</FileNamePattern>
			<MinIndex>1</MinIndex>
			<MaxIndex>7</MaxIndex>
		</rollingPolicy>

		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<MaxFileSize>10000KB</MaxFileSize>
		</triggeringPolicy>
	</appender>


	<!-- Log for status (to use with check_lsc_status_file.pl -->
	<!-- this file is erased at each execution -->
	<appender name="LSC_STATUS" class="ch.qos.logback.core.FileAppender">
		<append>false</append>
		<file>${logdir}/lsc.status</file>

		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
			<layout class="org.lsc.utils.output.LdifLayout">
				<Pattern>%date{MMM dd HH:mm:ss} - %-5level - %message%n</Pattern>
			</layout>
		</encoder>

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

	<!-- Special logger to have a LDIF file of all modifications applied -->
	<!-- this file is rotated every 10000KB, compressed and 7 files are kept for history -->
	<appender name="LDIF" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${logdir}/lsc.ldif</file>

		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
			<layout class="org.lsc.utils.output.LdifLayout">
				<Pattern>%m%n</Pattern>
				<onlyLdif>true</onlyLdif>
			</layout>
		</encoder>

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

		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
			<FileNamePattern>${logdir}/lsc.ldif.%i.gz</FileNamePattern>
			<MinIndex>1</MinIndex>
			<MaxIndex>7</MaxIndex>
		</rollingPolicy>

		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<MaxFileSize>10000KB</MaxFileSize>
		</triggeringPolicy>
	</appender>

	<!-- Main LSC messages -->
	<logger name="org.lsc" level="INFO">
		<appender-ref ref="LSC"/>
		<appender-ref ref="LSC_STATUS"/>
	</logger>
	<!-- Messages for LDIF output -->
	<logger name="lsc" level="INFO">
		<appender-ref ref="LDIF"/>
	</logger>
	<!-- Other messages -->
	<logger name="communicationLogger" level="WARN">
		<appender-ref ref="CONSOLE"/>
	</logger>
	<logger name="org.apache" level="WARN">
		<appender-ref ref="CONSOLE"/>
	</logger>
	<logger name="poolLogger" level="WARN">
		<appender-ref ref="CONSOLE"/>
	</logger>
	<!-- Root logger -->
	<root level="INFO">
		<appender-ref ref="CONSOLE"/>
	</root>
</configuration>

