1. 程式人生 > >logback日誌配置檔案

logback日誌配置檔案

logback日誌配置檔案

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds" debug="false">   
    <property name="logBase" value="/opt/applog/service" />
 	<!-- 系統日誌檔案-->
	<appender name="SystemLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${logBase}/system.log</file>
	    <encoder>
			<pattern>%d %-4level [%logger{40}] - %msg%n</pattern>
			<charset>UTF-8</charset>
		</encoder>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${logBase}/system.log.%d{yyyy-MM-dd-HH}</fileNamePattern>
		</rollingPolicy>
	</appender>
    <!-- 業務日誌檔案-->
	<appender name="BusinessLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${logBase}/kylin.log</file>
		<encoder>
			<pattern>%msg%n</pattern>
			<charset>UTF-8</charset>
		</encoder>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${logBase}/kylin.log.%d{yyyy-MM-dd-HH}</fileNamePattern>
		</rollingPolicy>
	</appender>
    <!--為具體logger指定appender-->
 	<logger level="INFO" name="businesslog" additivity="false">  
  		<appender-ref ref="BusinessLog" />  
 	</logger>   
 	<root level="INFO">
  		<appender-ref ref="SystemLog" />  
 	</root>   
</configuration>