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

	<property resource="application.properties" />

	<!-- 彩色日志 -->
	<!-- 彩色日志依赖的渲染类 -->
	<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
	<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
	<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
	<!-- 彩色日志格式 -->
	<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>

	<!-- appender -->
	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">




		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>${logger.level}</level>
		</filter>
		<!-- encoder 默认配置为PatternLayoutEncoder -->
		<encoder>
			<pattern>
				${CONSOLE_LOG_PATTERN}
			</pattern>
			<charset>UTF-8</charset>
		</encoder>
	</appender>
	<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">


		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!--日志文件输出的文件名 -->
			<FileNamePattern>/www/logs/${spring.application.name}.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<!--日志文件保留天数 -->
			<MaxHistory>10</MaxHistory>
		</rollingPolicy>
		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<pattern>
				%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger.%M - %m%n
			</pattern>
			<charset>UTF-8</charset>
		</encoder>
	</appender>




	<appender name="exceptionAdvice-log" class="ch.qos.logback.core.rolling.RollingFileAppender">


		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!--日志文件输出的文件名 -->
			<FileNamePattern>/www/logs/exceptionAdvice/exception-${spring.application.name}.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<!--日志文件保留天数 -->
			<MaxHistory>10</MaxHistory>
		</rollingPolicy>
		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<pattern>
				%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger.%M - %m%n
			</pattern>
			<charset>UTF-8</charset>
		</encoder>
	</appender>







	<appender name="aijia-all-system" class="ch.qos.logback.core.rolling.RollingFileAppender">

		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!--日志文件输出的文件名 -->
			<FileNamePattern>/www/logs/systemlog/system-${spring.application.name}.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<!--日志文件保留天数 -->
			<MaxHistory>10</MaxHistory>
		</rollingPolicy>
		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<pattern>
				%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger.%M - %m%n
			</pattern>
			<charset>UTF-8</charset>
		</encoder>
	</appender>

	
	
	  <!-- 1. 输出SQL 到控制台和文件-->
	 <logger name="org.hibernate.SQL" additivity="false"  >
	    <level value="info" />
	    <appender-ref ref="file" />
	    <appender-ref ref="stdout" />
	</logger>
	 <!-- 2. 输出SQL 的参数到控制台和文件-->
	<logger name="org.hibernate.type.descriptor.sql.BasicBinder" additivity="false" level="${logger.level}" >
		<level>${logger.level}</level>
	    <appender-ref ref="file" />
	    <appender-ref ref="stdout" />
	</logger>

	<!-- root logger -->
	<root level="info">
		<appender-ref ref="stdout" />
		<appender-ref ref="file" />
	</root>

    <logger name="com.alibaba.dubbo" level="ERROR"/>
    <logger name="org.apache.zookeeper.ZooKeeper" level="ERROR"/>

	
	<!-- custom logger -->
	<logger name="com.ssj" level="debug" additivity="false">
		<appender-ref ref="stdout" />
		<appender-ref ref="file" />
	</logger>

	<logger name="aijia" level="info">
		<appender-ref ref="aijia-all-system"/>
	</logger>
	<logger name="exceptionAdvice" level="error">
		<appender-ref ref="exceptionAdvice-log"/>
	</logger>

</configuration>