<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">

	<property name="LOG_HOME" value="/mdata/logs/task-%d{yyyy-MM-dd_HH}-%i.log" />
	<property name="CONSOLE_LOG_PATTERN"
			  value="[%X{username} %X{ip} %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}] : %msg%n" />

	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
		<encoder charset="UTF-8">
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

	<appender name="file"
			  class="ch.qos.logback.core.rolling.RollingFileAppender">
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>${LOG_HOME}</FileNamePattern>
			<MaxHistory>90</MaxHistory>
			<TimeBasedFileNamingAndTriggeringPolicy
					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<MaxFileSize>20MB</MaxFileSize>
			</TimeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>

		<encoder>
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

	<logger name="com.keao.edu" level="INFO" />

	<!--开发环境:打印控制台 -->
	<springProfile name="dev">
		<root level="INFO">
			<appender-ref ref="stdout" />
			<appender-ref ref="file" />
		</root>
	</springProfile>

	<springProfile name="test">
		<root level="INFO">
			<appender-ref ref="stdout" />
			<appender-ref ref="file" />
		</root>
	</springProfile>

	<!--生产环境:输出到文件 -->
	<springProfile name="prod">
		<root level="WARN">
			<appender-ref ref="stdout" />
			<appender-ref ref="file" />
		</root>
	</springProfile>

</configuration>
