logback.xml 2.6 KB
Newer Older
F
fang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
     <!-- 日志保存路径为tomcat下面的logs下面的mobileLog文件夹,logback会自动创建文件夹,这样设置了就可以输出日志文件了
         <substitutionProperty name="logbase" value="${catalina.base}/logs/mobileLog/"
         /> -->
     <substitutionProperty name="logbase" value="${user.dir}/logs/ " />
     <!-- 这个是要配置输出文件的 -->
     <jmxConfigurator />
     <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
         <layout class="ch.qos.logback.classic.PatternLayout">
              <pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
         </layout>
     </appender>
     <!-- 文件输出日志 (文件大小策略进行文件输出,超过指定大小对文件备份) -->
     <appender name="logfile"
         class="ch.qos.logback.core.rolling.RollingFileAppender">
         <Encoding>UTF-8</Encoding>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <File>${logbase}%d{yyyy-MM-dd}.log.html</File>
              <FileNamePattern>${logbase}.%d{yyyy-MM-dd}.log.html.zip
              </FileNamePattern>
         </rollingPolicy>
         <triggeringPolicy
              class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
              <MaxFileSize>2MB</MaxFileSize>
         </triggeringPolicy>
         <layout class="ch.qos.logback.classic.html.HTMLLayout">
              <pattern>%date%level%thread%10logger%file%line%msg</pattern>
         </layout>
     </appender>
     <!-- Output by Email -->
     <!--
     <appender name="Email" class="ch.qos.logback.classic.net.SMTPAppender">
         <SMTPHost>stmp host name</SMTPHost>
         <To>Email Address</To>
         <To>Email Address</To>
         <From>Email Address</From>
         <Subject>TESTING Email Function: %logger{20} - %m</Subject>
         <layout class="ch.qos.logback.classic.html.HTMLLayout">
              <pattern>%date%level%thread%10logger%file%line%msg</pattern>
         </layout>
     </appender> -->
 
     <!-- Output to Database -->
     <!--
     <appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
         <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
              <driverClass>com.mysql.jdbc.Driver</driverClass>
              <url>jdbc:mysql://localhost:3306/test</url>
              <user>root</user>
              <password>trend_dev</password>
         </connectionSource>
     </appender> -->
     <root>
         <level value="debug" />
         <appender-ref ref="logfile" />
         <appender-ref ref="logfile" />
     </root>
 
</configuration>