码迷,mamicode.com
首页 > 其他好文 > 详细

log4j2j配置

时间:2016-09-12 15:46:57      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

maven依赖

<properties>
<sl4j.version>1.7.7</sl4j.version>
<log4j2.version>2.1</log4j2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>

配置:(只有trace模式下,才能打印出sql的结果集)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="60">

<properties>
<property name="logPath">${profiles.logpath}</property>
</properties>

<Appenders>

<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%X{hdsf.traceid}] [%X{hdsf.appid}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c:%L - %msg%n" />
</Console>

<RollingFile name="root" filename="${logPath}/runtine.log" filepattern="${logPath}/%d{yyyyMMdd}-%i-root.log">
<PatternLayout pattern="[%X{hdsf.traceid}] [%X{hdsf.appid}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c:%L - %msg%n" />
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
<DefaultRolloverStrategy max="100"/>
</RollingFile>

</Appenders>


<Loggers>

<logger name="org.springframework.web.method.support" level="INFO"></logger>
<logger name="org.springframework.context.event" level="INFO"></logger>
<logger name="org.springframework.beans.factory.xml" level="INFO"></logger>
<logger name="org.springframework.context.annotation" level="INFO"></logger>
<logger name="org.springframework.web.servlet.resource" level="INFO"></logger>
<logger name="org.apache.velocity" level="INFO"></logger>
<logger name="org.springframework.beans" level="INFO"></logger>

<logger name="org.springframework.core" level="INFO"></logger>
<logger name="org.springframework.web" level="INFO"></logger>

<logger name="org.apache.cxf" level="INFO"></logger>

<Root level="trace">
<AppenderRef ref="Console" />
<AppenderRef ref="root" />
</Root>

</Loggers>
</Configuration>

log4j2j配置

标签:

原文地址:http://www.cnblogs.com/qiumingcheng/p/5864840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!