<?xml version="1.0" encoding="UTF-8"?>
<configuration><!-- 使用spring profile 来管理多环节log文件 -->
	<logger name="com.yd.dal.mapper" level="DEBUG"/>
	<springProfile name="local"> <!-- local 环境 -->
		<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"><!-- 控制台输出 -->
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern><!--格式化输出：%d表示日期，%thread表示线程名，%-5level：级别从左显示5个字符宽度%msg：日志消息，%n是换行符 -->
			</encoder>
		</appender>
		
		<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- 按照每天生成日志文件 -->
			<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
				<FileNamePattern>opt/log/yd/yd-api.%d{yyyy-MM-dd}.log</FileNamePattern><!--日志文件输出的文件名 -->
				<MaxHistory>30</MaxHistory><!--日志文件保留天数 -->
			</rollingPolicy>
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern><!--格式化输出：%d表示日期，%thread表示线程名，%-5level：级别从左显示5个字符宽度%msg：日志消息，%n是换行符 -->
			</encoder>
			<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"><!--日志文件最大的大小 -->
				<MaxFileSize>10MB</MaxFileSize>
			</triggeringPolicy>
		</appender>
		
		<appender name="accurateQuotationFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
			<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
				<FileNamePattern>opt/log/yd/accurate.%d{yyyy-MM-dd}.log</FileNamePattern>
				<MaxHistory>30</MaxHistory><!--日志文件保留天数 -->
			</rollingPolicy>
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
			<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
				<MaxFileSize>10MB</MaxFileSize>
			</triggeringPolicy>
		</appender>
	</springProfile>
	
	<springProfile name="dev,stage"> <!-- dev stage 环境 -->
		<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
		</appender>
		
		<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
			<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
				<FileNamePattern>opt/log/yd/yd-api.%d{yyyy-MM-dd}.log</FileNamePattern>
				<MaxHistory>30</MaxHistory>
			</rollingPolicy>
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
			<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
				<MaxFileSize>10MB</MaxFileSize>
			</triggeringPolicy>
		</appender>

		<appender name="accurateQuotationFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
			<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
				<FileNamePattern>opt/log/yd/accurate.%d{yyyy-MM-dd}.log</FileNamePattern>
				<MaxHistory>30</MaxHistory><!--日志文件保留天数 -->
			</rollingPolicy>
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
			<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
				<MaxFileSize>10MB</MaxFileSize>
			</triggeringPolicy>
		</appender>
	</springProfile>

	<springProfile name="prod"><!--  prod环境 -->
		<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
		</appender>

		<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
			<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
				<FileNamePattern>opt/log/yd/yd-api.%d{yyyy-MM-dd}.log</FileNamePattern>
				<MaxHistory>30</MaxHistory>
			</rollingPolicy>
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
			<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
				<MaxFileSize>10MB</MaxFileSize>
			</triggeringPolicy>
		</appender>

		<appender name="accurateQuotationFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
			<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
				<FileNamePattern>opt/log/yd/accurate.%d{yyyy-MM-dd}.log</FileNamePattern>
				<MaxHistory>30</MaxHistory><!--日志文件保留天数 -->
			</rollingPolicy>
			<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
			</encoder>
			<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
				<MaxFileSize>10MB</MaxFileSize>
			</triggeringPolicy>
		</appender>
	</springProfile>

    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root> 
    
	<logger name="accurateQuotation" level="WARN" additivity="false">
		<appender-ref ref="STDOUT" />
		<appender-ref ref="accurateQuotationFILE"/>
	</logger> 
</configuration>