logback.xml 配置文件(logback.xml在哪里)

  本篇文章为你整理了logback.xml 配置文件(logback.xml在哪里)的详细内容,包含有logback.xml配置文件加载顺序 logback.xml在哪里 logback.xml不起作用 logback配置文件详解 logback.xml 配置文件,希望能帮助你了解 logback.xml 配置文件。

  logback.xml

  

 ?xml version="1.0" encoding="UTF-8"? 

 

   configuration

   !--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径--

   !-- property name="LOG_HOME" value="${LOG_HOME}" / --

   property name="LOG_HOME" value="./logs" /

   appender name="CONSOLE"

   encoder charset="UTF-8"

   !--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %highlight([%-5level] %logger{50} - %msg%n) /pattern

   !-- charset UTF-8 /charset -- !--注释掉,解决Windows CMD 运行时 log 乱码--

   /encoder

   /appender

  
!--日志文件输出的文件名--

   fileNamePattern ${LOG_HOME}/debug.log.%d{yyyy-MM-dd} /fileNamePattern

   !--日志文件保留天数--

   maxHistory 15 /maxHistory

   !--日志文件最大的大小--

   !-- MaxFileSize 1000MB /MaxFileSize --

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   appender name="SYS_INFO"

   File ${LOG_HOME}/info.log /File

   append true /append

   !--过滤器,只打INFO级别的日志,日志文件最多保留15天(如果是按天滚动)--

   filter

   level INFO /level

   onMatch ACCEPT /onMatch !-- 表示匹配该级别及以上 --

   onMismatch DENY /onMismatch !-- 表示不匹配该级别以下的 --

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/info.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   !--日志文件保留天数--

   maxHistory ${maxHistory} /maxHistory

   !--日志文件最大的大小--

   !-- MaxFileSize 1000MB /MaxFileSize --

   !--启用删除删除功能,默认为自动删除--

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   appender name="SYS_ERROR"

   File ${LOG_HOME}/error.log /File

   append true /append

   !--过滤器,只打ERROR级别的日志--

   filter

   level ERROR /level

   onMatch ACCEPT /onMatch

   onMismatch DENY /onMismatch

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/error.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   appender name="SYS_WARN"

   File ${LOG_HOME}/warn.log /File

   append true /append

   !--过滤器,只打WARN级别的日志--

   filter

   level WARN /level

   onMatch ACCEPT /onMatch

   onMismatch DENY /onMismatch

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/warn.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   !--不同业务产生的日志打印到不同文件中--

   appender name="API_HIS_INFO"

   File ${LOG_HOME}/api_his_info.log /File

   append true /append

   filter

   level INFO /level

   onMatch ACCEPT /onMatch

   onMismatch DENY /onMismatch

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/api_his_info.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   appender name="API_HIS_ERROR"

   File ${LOG_HOME}/error_api_his.log /File

   append true /append

   filter

   level ERROR /level

   onMatch ACCEPT /onMatch

   onMismatch DENY /onMismatch

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/error_api_his.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   appender name="API_IRON_INFO"

   File ${LOG_HOME}/api_iron_info.log /File

   append true /append

   filter

   level INFO /level

   onMatch ACCEPT /onMatch

   onMismatch DENY /onMismatch

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/api_iron_info.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   appender name="API_IRON_ERROR"

   File ${LOG_HOME}/error_api_iron.log /File

   append true /append

   filter

   level ERROR /level

   onMatch ACCEPT /onMatch

   onMismatch DENY /onMismatch

   /filter

   rollingPolicy

   fileNamePattern ${LOG_HOME}/error_api_iron.log.%d{yyyy-MM-dd} /fileNamePattern

   maxHistory 15 /maxHistory

   cleanHistoryOnStart true /cleanHistoryOnStart

   /rollingPolicy

   encoder charset="UTF-8"

   pattern [%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n /pattern

   charset UTF-8 /charset

   /encoder

   /appender

   !--设置 com.iron.demo 包空间下面的日志 level 显示--

   logger name="com.iron.demo" level="INFO"/

  
!-- 不同的业务逻辑日志打印到指定文件中 info 和 error 分开 additivity=false 不会加到 SYS_XXX 默认系统日志中,在使用 Spring Boot Admin 时,需要将这个去掉,因为Spring Boot Admin-Client 只能指定一个日志文件, --

   logger name="apiHis" level="INFO"

   appender-ref ref="API_HIS_INFO"/

   /logger

   logger name="apiIron" additivity="false" level="INFO"

   !--打到控制台--

   appender-ref ref="CONSOLE"/

   appender-ref ref="API_IRON_INFO"/

   appender-ref ref="API_IRON_ERROR"/

   /logger

   !--系统级的日志(默认) info和error分开打印--

   root level="INFO"

   appender-ref ref="CONSOLE"/

   appender-ref ref="SYS_DEBUG"/

   appender-ref ref="SYS_INFO"/

   appender-ref ref="SYS_WARN"/

   appender-ref ref="SYS_ERROR"/

   /root

   /configuration

 

  

  以上就是logback.xml 配置文件(logback.xml在哪里)的详细内容,想要了解更多 logback.xml 配置文件的内容,请持续关注盛行IT软件开发工作室。

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: