log4j2的xml的配置样例
log4j2.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <Configuration status="warn" name="huawy-repayment-service" packages=""> 3 <Appenders> 4 <Console name="Console" target="SYSTEM_OUT"> 5 <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> 6 </Console> 7 8 <RollingFile name="RollingFile" fileName="/data/logs/hwy/xx.log" 9 filePattern="/data/logs/hwy/$${date:yyyy-MM}/xx-%d{MM-dd-yyyy}-%i.log.gz"> 10 <PatternLayout> 11 <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> 12 </PatternLayout> 13 <Policies> 14 <TimeBasedTriggeringPolicy /> 15 <SizeBasedTriggeringPolicy size="250 MB" /> 16 </Policies> 17 </RollingFile> 18 </Appenders> 19 <Loggers> 20 <Root level="INFO"> 21 <AppenderRef ref="RollingFile" /> 22 <AppenderRef ref="Console" /> 23 </Root> 24 <logger name="com.xx.xxDao" level="TRACE" additivity="false"> 25 <AppenderRef ref="Console" /> 26 </logger> 27 </Loggers> 28 </Configuration>
上面代码中的24行对某个包中的日志级别做对应的修改,如果dao层用的myBatis,那么日志将打印具体的SQL信息