log4j2.xml 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. status : 这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,会看到log4j2内部各种详细输出
  4. monitorInterval : Log4j能够自动检测修改配置文件和重新配置本身, 设置间隔秒数。
  5. -->
  6. <Configuration status="error" monitorInterval="30">
  7. <Properties>
  8. <Property name="log-path">logs/smart-admin/dev/logs</Property>
  9. </Properties>
  10. <Appenders>
  11. <Console name="Console" target="SYSTEM_OUT">
  12. <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
  13. <PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
  14. </Console>
  15. <RollingFile name="debug" fileName="${log-path}/debug/smart-admin_debug.log"
  16. filePattern="${log-path}/debug/smart-admin_debug_%d{yyyy-MM-dd}-%i.log">
  17. <Filters>
  18. <ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
  19. <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
  20. </Filters>
  21. <PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
  22. <Policies>
  23. <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
  24. <SizeBasedTriggeringPolicy size="50 MB"/>
  25. </Policies>
  26. <DefaultRolloverStrategy max="30">
  27. <Delete basePath="${log-path}/debug" maxDepth="1">
  28. <IfFileName glob="smart-admin_debug_*.log"/>
  29. <IfLastModified age="15d"/>
  30. </Delete>
  31. </DefaultRolloverStrategy>
  32. </RollingFile>
  33. <RollingFile name="info" fileName="${log-path}/info/smart-admin_info.log"
  34. filePattern="${log-path}/info/smart-admin_info_%d{yyyy-MM-dd}-%i.log">
  35. <Filters>
  36. <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
  37. <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
  38. </Filters>
  39. <PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
  40. <Policies>
  41. <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
  42. <SizeBasedTriggeringPolicy size="50 MB"/>
  43. </Policies>
  44. <DefaultRolloverStrategy max="30">
  45. <Delete basePath="${log-path}/info" maxDepth="1">
  46. <IfFileName glob="smart-admin_info_*.log"/>
  47. <IfLastModified age="15d"/>
  48. </Delete>
  49. </DefaultRolloverStrategy>
  50. </RollingFile>
  51. <RollingFile name="warn" fileName="${log-path}/warn/smart-admin_warn.log"
  52. filePattern="${log-path}/warn/smart-admin_warn_%d{yyyy-MM-dd}-%i.log">
  53. <Filters>
  54. <ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
  55. <ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
  56. </Filters>
  57. <PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
  58. <Policies>
  59. <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
  60. <SizeBasedTriggeringPolicy size="50 MB"/>
  61. </Policies>
  62. <DefaultRolloverStrategy max="30">
  63. <Delete basePath="${log-path}/warn" maxDepth="1">
  64. <IfFileName glob="smart-admin_warn_*.log"/>
  65. <IfLastModified age="15d"/>
  66. </Delete>
  67. </DefaultRolloverStrategy>
  68. </RollingFile>
  69. <RollingFile name="error" fileName="${log-path}/error/smart-admin_error.log"
  70. filePattern="${log-path}/error/smart-admin_error_%d{yyyy-MM-dd}-%i.log">
  71. <Filters>
  72. <ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
  73. <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
  74. </Filters>
  75. <PatternLayout pattern="[%d][%-5p][%t] %m (%F:%L)%n"/>
  76. <Policies>
  77. <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
  78. <SizeBasedTriggeringPolicy size="10 MB"/>
  79. </Policies>
  80. <DefaultRolloverStrategy max="30">
  81. <Delete basePath="${log-path}/error" maxDepth="1">
  82. <IfFileName glob="smart-admin_error_*.log"/>
  83. <IfLastModified age="15d"/>
  84. </Delete>
  85. </DefaultRolloverStrategy>
  86. </RollingFile>
  87. </Appenders>
  88. <Loggers>
  89. <Root level="debug">
  90. <AppenderRef ref="Console"/>
  91. <AppenderRef ref="debug"/>
  92. <AppenderRef ref="info"/>
  93. <AppenderRef ref="warn"/>
  94. <AppenderRef ref="error"/>
  95. </Root>
  96. </Loggers>
  97. </Configuration>