Log4j2 配置

 

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="off" monitorInterval="1800">

<properties>
<property name="LOG_HOME">d:/logs</property>
<property name="FILE_NAME">error_log</property>
</properties>

<Appenders>

<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>

<RollingRandomAccessFile name="running-log"
fileName="${LOG_HOME}/${FILE_NAME}.log" filePattern="${LOG_HOME}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout
pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
<DefaultRolloverStrategy max="20" />
</RollingRandomAccessFile>
</Appenders>

<Loggers>
<Logger name="com.boguan.bte.controller.TestController" level="error"
additivity="true">
<AppenderRef ref="running-log" />
</Logger>
<Root level="error">
<AppenderRef ref="running-log" />
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>

 

 设置这个属性:

 -Dlog4j.configurationFile="C:\Users\lenovo\workspace\BTE_PRJ\src\log4j2.xml"

 

 

 

posted @ 2016-06-28 14:49  Brook Legend  阅读(585)  评论(0编辑  收藏  举报