logback.xml 10.5 KB
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

	<property name="log.path" value="/WMSlog" />
	<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
	<property resource="application-druid.properties"/>
	<property name="dataSource" value="${spring.datasource.type}" />
	<property name="driverClassName" value="${spring.datasource.driverClassName}" />
	<property name="url" value="${spring.datasource.druid.master.url}" />
	<property name="username" value="${spring.datasource.druid.master.username}" />
	<property name="password" value="${spring.datasource.druid.master.password}" />

	<!-- 控制台输出 -->
	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>${log.pattern}</pattern>
		</encoder>
        <!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
            <!--<level>INFO</level>-->
            <!--<onMatch>ACCEPT</onMatch>-->
            <!--<onMismatch>DENY</onMismatch>-->
        <!--</filter>-->
	</appender>

	<!-- 系统日志输出 只记录DEBUG级别-->
	<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${log.path}/sys-debug/sys-debug.%d{yyyy-MM-dd}.log</fileNamePattern>
			<!-- 日志最大的历史 60天 -->
			<maxHistory>60</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>${log.pattern}</pattern>
		</encoder>
		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<!-- 文件大小触发重写新文件 -->
			<MaxFileSize>10MB</MaxFileSize>
		</triggeringPolicy>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>DEBUG</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<!-- 系统日志输出 只记录INFO级别-->
	<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
	    <!--<file>${log.path}/sys-info/sys-info.log</file>-->
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!-- 按天回滚 daily -->
			<fileNamePattern>${log.path}/sys-info/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
			<!-- 日志最大的历史 60天 -->
			<maxHistory>60</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>${log.pattern}</pattern>
		</encoder>
		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<!-- 文件大小触发重写新文件 -->
			<MaxFileSize>10MB</MaxFileSize>
		</triggeringPolicy>

		<filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
	</appender>

	<!-- 系统日志输出 只记录WARN级别-->
	<appender name="file_warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!-- 按天回滚 daily -->
			<fileNamePattern>${log.path}/sys-warn/sys-warn.%d{yyyy-MM-dd}.log</fileNamePattern>
			<!-- 日志最大的历史 60天 -->
			<maxHistory>60</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>${log.pattern}</pattern>
		</encoder>
		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<!-- 文件大小触发重写新文件 -->
			<MaxFileSize>10MB</MaxFileSize>
		</triggeringPolicy>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>WARN</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>-->
	</appender>


	<!-- 系统日志输出 只记录ERROR级别-->
	<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/sys-error/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
			<!-- 日志最大的历史 60天 -->
			<maxHistory>60</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<!-- 文件大小触发重写新文件 -->
			<MaxFileSize>10MB</MaxFileSize>
		</triggeringPolicy>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>

	<!--<appender name="u8_receipt" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
		<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
			<!--<fileNamePattern>${log.path}/u8/receipt/error.%d{yyyy-MM-dd}.log</fileNamePattern>-->
			<!--&lt;!&ndash; 日志最大的历史 60天 &ndash;&gt;-->
			<!--<maxHistory>60</maxHistory>-->
		<!--</rollingPolicy>-->
		<!--<encoder>-->
			<!--<pattern>${log.pattern}</pattern>-->
		<!--</encoder>-->
		<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
			<!--&lt;!&ndash; 文件大小触发重写新文件 &ndash;&gt;-->
			<!--<MaxFileSize>10MB</MaxFileSize>-->
		<!--</triggeringPolicy>-->
		<!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
			<!--<level>ERROR</level>-->
			<!--<onMatch>ACCEPT</onMatch>-->
			<!--<onMismatch>DENY</onMismatch>-->
		<!--</filter>-->
	<!--</appender>-->
	<!--<appender name="u8_shipment" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
		<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
			<!--<fileNamePattern>${log.path}/u8/shipment/error.%d{yyyy-MM-dd}.log</fileNamePattern>-->
			<!--&lt;!&ndash; 日志最大的历史 60天 &ndash;&gt;-->
			<!--<maxHistory>60</maxHistory>-->
		<!--</rollingPolicy>-->
		<!--<encoder>-->
			<!--<pattern>${log.pattern}</pattern>-->
		<!--</encoder>-->
		<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
			<!--&lt;!&ndash; 文件大小触发重写新文件 &ndash;&gt;-->
			<!--<MaxFileSize>10MB</MaxFileSize>-->
		<!--</triggeringPolicy>-->
		<!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
			<!--<level>ERROR</level>-->
			<!--<onMatch>ACCEPT</onMatch>-->
			<!--<onMismatch>DENY</onMismatch>-->
		<!--</filter>-->
	<!--</appender>-->

	<!--<appender name="u8_basicData" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
		<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
			<!--<fileNamePattern>${log.path}/u8/basicData/error.%d{yyyy-MM-dd}.log</fileNamePattern>-->
			<!--&lt;!&ndash; 日志最大的历史 60天 &ndash;&gt;-->
			<!--<maxHistory>60</maxHistory>-->
		<!--</rollingPolicy>-->
		<!--<encoder>-->
			<!--<pattern>${log.pattern}</pattern>-->
		<!--</encoder>-->
		<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
			<!--&lt;!&ndash; 文件大小触发重写新文件 &ndash;&gt;-->
			<!--<MaxFileSize>10MB</MaxFileSize>-->
		<!--</triggeringPolicy>-->
		<!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
			<!--<level>ERROR</level>-->
			<!--<onMatch>ACCEPT</onMatch>-->
			<!--<onMismatch>DENY</onMismatch>-->
		<!--</filter>-->
	<!--</appender>-->
	<!--<logger name="com.huaheng.api.U8.controller" level="INFO">-->
		<!--<appender-ref ref="u8_receipt" />-->
		<!--<appender-ref ref="u8_shipment" />-->
		<!--<appender-ref ref="u8_basicData" />-->
	<!--</logger>-->

	<!--<appender name="qg" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
		<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
			<!--<fileNamePattern>${log.path}/qg/error.%d{yyyy-MM-dd}.log</fileNamePattern>-->
			<!--&lt;!&ndash; 日志最大的历史 60天 &ndash;&gt;-->
			<!--<maxHistory>60</maxHistory>-->
		<!--</rollingPolicy>-->
		<!--<encoder>-->
			<!--<pattern>${log.pattern}</pattern>-->
		<!--</encoder>-->
		<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
			<!--&lt;!&ndash; 文件大小触发重写新文件 &ndash;&gt;-->
			<!--<MaxFileSize>10MB</MaxFileSize>-->
		<!--</triggeringPolicy>-->
		<!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
			<!--<level>ERROR</level>-->
			<!--<onMatch>ACCEPT</onMatch>-->
			<!--<onMismatch>DENY</onMismatch>-->
		<!--</filter>-->
	<!--</appender>-->

	<!--<logger name="com.huaheng.api.SSP.controller" level="INFO">-->
		<!--<appender-ref ref="qg" />-->
	<!--</logger>-->

	
	<!--&lt;!&ndash; 用户访问日志输出  &ndash;&gt;-->
    <!--<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
		<!--<file>${log.path}/sys-user.log</file>-->
        <!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
            <!--&lt;!&ndash; 按天回滚 daily &ndash;&gt;-->
            <!--<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>-->
            <!--&lt;!&ndash; 日志最大的历史 60天 &ndash;&gt;-->
            <!--<maxHistory>60</maxHistory>-->
        <!--</rollingPolicy>-->
        <!--<encoder>-->
            <!--<pattern>${log.pattern}</pattern>-->
        <!--</encoder>-->
    <!--</appender>-->

    <!--将日志传到数据库 表logging_event-->
	<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
		<connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
			<dataSource class="${dataSource}">
				<driverClassName>${driverClassName}</driverClassName>
				<url>${url}</url>
				<username>${username}</username>
				<password>${password}</password>
			</dataSource>
		</connectionSource>

		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<!-- 显示形成的sql、使用的参数、结果集 -->
    <!--<logger name="java.sql" level="DEBUG" >-->
		<!--<appender-ref ref="console" />-->
		<!--<appender-ref ref="file_info" />-->
	<!--</logger>-->

    <!--<logger name="org.springframework.jdbc" level="DEBUG">-->
        <!--<appender-ref ref="console" />-->
        <!--<appender-ref ref="file_info" />-->
    <!--</logger>-->
	<!--<logger name="com.huaheng" level="debug" />-->




	<!--系统操作日志-->
    <root level="INFO">
		<appender-ref ref="console" />
		<appender-ref ref="file_debug"/>
        <appender-ref ref="file_info" />
		<appender-ref ref="file_warn"/>
		<appender-ref ref="file_error"/>
		<appender-ref ref="DB"/>
    </root>

	
	<!--系统用户操作日志-->
    <!--<logger name="sys-user" level="debug">-->
        <!--<appender-ref ref="sys-user"/>-->
    <!--</logger>-->
</configuration>