<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<!-- 定义日志输出的颜色，用于控制台美化 -->
	<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %-30.30thread %-40.40logger{36} : %msg%n"/>
	<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %-30.30thread %-40.40logger{36} : %msg%n"/>

	<!-- 日志文件存储路径，可根据实际项目调整 -->
	<property name="LOG_FILE_PATH" value="./logs"/>
	<property name="LOG_FILE_NAME" value="application.log"/>
	<property name="LOG_ARCHIVE_PATH" value="${LOG_FILE_PATH}/archive"/>

	<!-- 定义控制台 appender -->
	<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

	<!-- 定义文件 appender，用于输出到 application.log 文件，并按日期滚动 -->
	<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${LOG_FILE_PATH}/${LOG_FILE_NAME}</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${LOG_ARCHIVE_PATH}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<maxHistory>30</maxHistory>  <!-- 最多保留30天的日志文件 -->
		</rollingPolicy>
		<encoder>
			<pattern>${FILE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

	<appender name="MybatisAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${LOG_FILE_PATH}/sqlDal.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${LOG_ARCHIVE_PATH}/sqlDal.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<maxHistory>15</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>${FILE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

	<!-- 定义所有其他日志记录器 -->
	<root level="INFO">
		<appender-ref ref="CONSOLE"/>
		<appender-ref ref="FILE"/>
	</root>

	<!-- 定义 spring boot 特定日志记录器，针对框架内部日志输出 -->
	<logger name="org.springframework" level="INFO" />

	<!-- 定义 mybatis 日志记录器，可以单独控制 sql 日志的输出级别 -->
<!--	<logger name="org.mybatis" level="INFO" />-->
	<!-- MyBatis SQL 日志 -->
	<Logger name="org.apache.ibatis" level="DEBUG" additivity="false">
		<AppenderRef ref="MybatisAppender"/>
	</Logger>
	<logger name="org.jeecg.modules.database.mapper" level="DEBUG" additivity="false">
		<appender-ref ref="MybatisAppender"/>
	</logger>
	<logger name="org.apache.ibatis" level="INFO" />
	<logger name="org.jeecg.modules.database.service.impl" level="INFO"></logger>
	<logger name="org.jeecg.modules.database.controller" level="INFO"></logger>




</configuration>