All Downloads are FREE. Search and download functionalities are using the official Maven repository.

config.xml.logback-spring.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
	
	<!-- 控制台输出 -->
	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
		<encoder charset="UTF-8">	<!-- encoder 可以指定字符集,对于中文输出有意义 -->
			<pattern>
				[%-5level] [%date{yyyy-MM-dd HH:mm:ss:SSS}] %logger{36} [%line] - %msg%n
			</pattern>
		</encoder>
	</appender>
	
	<!-- 时间滚动输出 level为 DEBUG 日志 -->
	<appender name="file-debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>DEBUG</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY </onMismatch>
		</filter>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>./logs/debug.%d{yyyy-MM-dd}.log</FileNamePattern>
			<MaxHistory>30</MaxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>
				%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
			</pattern>
		</encoder>
	</appender>

	<!-- 时间滚动输出 level为 INFO 日志 -->
	<appender name="file-info" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>INFO</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY </onMismatch>
		</filter>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>./logs/info.%d{yyyy-MM-dd}.log</FileNamePattern>
			<MaxHistory>30</MaxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>
				%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
			</pattern>
		</encoder>
	</appender>

	<!-- 时间滚动输出 level为ERROR 日志 -->
	<appender name="file-error" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY </onMismatch>
		</filter>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>./logs/error.%d{yyyy-MM-dd}.log</FileNamePattern>
			<MaxHistory>30</MaxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>
				%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
			</pattern>
		</encoder>
	</appender>

	<!-- 很多人使用Mybatis的时候,控制台不能输出SQL语句,造成调试困难。只需要让DAO层的日志级别调整为DEBUG就可以了 -->
	<logger name="top.lshaci" level="debug" />
	
	<!-- 指定项目可输出的最低级别日志 -->
	<root level="error">
		<appender-ref ref="console" />
		<appender-ref ref="file-debug" />
		<appender-ref ref="file-info" />
		<appender-ref ref="file-error" />
	</root>
</configuration>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy