logback.xml 模板

  1. xml version="1.0" encoding="UTF-8"?> 
  2.  
  3. <configuration 
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5. xsi:noNamespaceSchemaLocation="http://www.padual.com/java/logback.xsd" 
  6. scan="true" scanPeriod="60 seconds" debug="false"> 
  7.  
  8.  
  9.  
  10.  
  11. <property name = "log.level" value = "debug"/> 
  12.  
  13. <property name = "log.maxHistory" value = "30"/> 
  14.  
  15. <property name = "log.filePath" value = "${catalina.base}/logs/webapps"/> 
  16.  
  17. <property name = "log.pattern" value = "%d{yyyy-MM-dd HH:mm:ss:SSS} [%thr ead] %-5level %logger{50} - %msg%n"/> 
  18.  
  19.  
  20.  
  21.  
  22. <appender name = "consoleAppender" class = "ch.qos.logback.core.ConsoleAppender"> 
  23. <encoder> 
  24. <pattern>${log.pattern}pattern
  25. encoder
  26. appender
  27.  
  28.  
  29.  
  30. <appender name = "debugAppender" class = "ch.qos.logback.core.rolling.RollingFileAppender"> 
  31.  
  32. <file>${log.filePath}/debug.logfile
  33. <rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
  34.  
  35. <fileNamePattern>${log.filePath}/debug/debug.%d{yyyy-MM-dd}.log.gzfileNamePattern
  36.  
  37. <maxHistory>${log.maxHistory}maxHistory
  38. rollingPolicy
  39. <encoder> 
  40. <pattern>${log.pattern}pattern
  41. encoder
  42.  
  43.  
  44. <filter class = "ch.qos.logback.classic.filter.LevelFilter"> 
  45. <level>DEBUGlevel
  46. <onMatch>ACCEPTonMatch
  47. <onMismatch>DENYonMismatch
  48. filter
  49. appender
  50.  
  51.  
  52. <appender name = "infoAppender" class = "ch.qos.logback.core.rolling.RollingFileAppender"> 
  53.  
  54. <file>${log.filePath}/info.logfile
  55. <rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
  56.  
  57. <fileNamePattern>${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gzfileNamePattern
  58.  
  59. <maxHistory>${log.maxHistory}maxHistory
  60. rollingPolicy
  61. <encoder> 
  62. <pattern>${log.pattern}pattern
  63. encoder
  64. <filter class = "ch.qos.logback.classic.filter.LevelFilter"> 
  65. <level>INFOlevel
  66. <onMatch>ACCEPTonMatch
  67. <onMismatch>DENYonMismatch
  68. filter
  69. appender
  70.  
  71.  
  72. <appender name = "warnAppender" class = "ch.qos.logback.core.rolling.RollingFileAppender"> 
  73.  
  74. <file>${log.filePath}/warn.logfile
  75. <rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
  76.  
  77. <fileNamePattern>${log.filePath}/warn/warn.%d{yyyy-MM-dd}.log.gzfileNamePattern
  78.  
  79. <maxHistory>${log.maxHistory}maxHistory
  80. rollingPolicy
  81. <encoder> 
  82. <pattern>${log.pattern}pattern
  83. encoder
  84. <filter class = "ch.qos.logback.classic.filter.LevelFilter"> 
  85. <level>WARNlevel
  86. <onMatch>ACCEPTonMatch
  87. <onMismatch>DENYonMismatch
  88. filter
  89. appender
  90.  
  91.  
  92. <appender name = "errorAppender" class = "ch.qos.logback.core.rolling.RollingFileAppender"> 
  93.  
  94. <file>${log.filePath}/error.logfile
  95. <rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
  96.  
  97. <fileNamePattern>${log.filePath}/error/error.%d{yyyy-MM-dd}.log.gzfileNamePattern
  98.  
  99. <maxHistory>${log.maxHistory}maxHistory
  100. rollingPolicy
  101. <encoder> 
  102. <pattern>${log.pattern}pattern
  103. encoder
  104. <filter class = "ch.qos.logback.classic.filter.LevelFilter"> 
  105. <level>ERRORlevel
  106. <onMatch>ACCEPTonMatch
  107. <onMismatch>DENYonMismatch
  108. filter
  109. appender
  110.  
  111.  
  112. <logger name = "com.ryanjie.o2o" level = "${log.level}" additivity = "true"> 
  113.  
  114. <appender-ref ref = "debugAppender"/> 
  115. <appender-ref ref = "infoAppender"/> 
  116. <appender-ref ref = "warnAppender"/> 
  117. <appender-ref ref = "eeorAppender"/> 
  118. logger
  119.  
  120.  
  121. <root level = "info"> 
  122. <appender-ref ref = "consoleAppender"/> 
  123. root
  124. configuration

转载于:https://www.cnblogs.com/Ryanjie/p/10142672.html

你可能感兴趣的:(logback.xml 模板)