首页 / 资讯中心 / 文章详情

log4j2.xml配置(简单易用版)

log4j2.xml配置(简单易用版) ★ FEATURED ARTICLE
log4j2.xml配置一、pom.xml二、log4j2.xml一、pom.xmldependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdexclusionsexclusiongroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-logging/artifactId/exclusion/exclusions/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-log4j2/artifactIdversion3.5.7/version/dependency二、log4j2.xml?xml version1.0 encodingUTF-8 ?ConfigurationstatusWARNpropertiespropertynameLOG_PATTERN%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%5level} - [%40.40thread] [%style{%16X{traceId}}{magenta}] %style{%-40.40logger{39}}{cyan} %style{at %l}{yellow} : %m%n%wEx/property/propertiesAppendersConsolenameConsoletargetSYSTEM_OUTThresholdFilterlevelDEBUGonMatchACCEPTonMismatchDENY/!-- disableAnsifalse开启Ansi颜色 --PatternLayoutpattern${LOG_PATTERN}disableAnsifalsecharsetUTF-8//ConsoleRollingFilenameRollingFilefileNamelog/log.logfilePatternlog/log-%d{yyyy-MM-dd}.logThresholdFilterlevelDEBUGonMatchACCEPTonMismatchDENY/PatternLayoutpattern${LOG_PATTERN}disableAnsitruecharsetUTF-8/Policies!-- 时间触发策略每天滚动一次且对齐到凌晨modulatetrue --TimeBasedTriggeringPolicyinterval1modulatetrue//PoliciesDefaultRolloverStrategy!-- 删除10天前的日志 --DeletebasePathlogmaxDepth1IfFileNamegloblog-*.log/IfLastModifiedage10d//Delete/DefaultRolloverStrategy/RollingFile/AppendersLoggersRootlevelINFOAppenderRefrefConsole/AppenderRefrefRollingFile//Root!-- 设置了name和debug就筛选出了mybatis的sql日志--Loggernamecom.example.demolevelDEBUG//Loggers/Configuration参考[1]:log4j2 实际使用详解[2]:log4j2.xml
阅读完成 · 觉得有帮助?
咨询建站