<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Spring-boot Examples
  ~
  ~ Copyright (c) 2020-2021. Elex. All Rights Reserved.
  ~ https://www.elex-project.com/
  -->

<configuration>
	<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
	<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

	<springProperty name="LOG_DIR" source="logging.path"
	                defaultValue="${user.home}/logs"/>
	<property name="LOG_PATH" value="${LOG_DIR}/stephanie.log"/>

	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

	<appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<charset>UTF-8</charset>
			<pattern>${FILE_LOG_PATTERN}</pattern>
		</encoder>
		<file>${LOG_PATH}</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${LOG_DIR}/sebastian_%d{yyyy-MM-dd}_%i.log.gz</fileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>10MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<maxHistory>60</maxHistory>
		</rollingPolicy>
	</appender>

	<logger name="kr.pe.elex" level="debug" additivity="false">
		<appender-ref ref="CONSOLE"/>
		<appender-ref ref="ROLLING-FILE"/>
	</logger>
	<root level="info">
		<appender-ref ref="CONSOLE"/>
		<appender-ref ref="ROLLING-FILE"/>
	</root>

</configuration>
