log4j笔记

log2j.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN"  monitorInterval="30">
   <properties>
      <property name="LOG_HOME">/output/logs</property>
      <!-- 日志备份目录 -->
      <property name="SERVER_NAME">${module.name}</property>
   </properties>
   <appenders>
      <Console name="Console" target="SYSTEM_OUT">
         <PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %level [%C{1}:%L] - %msg%n" />
      </Console>
      <RollingFile name="RollingFile"
         fileName="${LOG_HOME}/dev/${SERVER_NAME}.log"
         filePattern="${LOG_HOME}/dev/${SERVER_NAME}.%d{yyyy-MM-dd}.%i.log">
         <PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %level [%C{36}.%M] - %msg%n" />
            <Policies>  
                <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
         <Filters>
            <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY" />
         </Filters>
            <DefaultRolloverStrategy>
                <!-- 删除指定目录下7天之前的日志-->
                <Delete basePath="${LOG_HOME}" maxDepth="2">
                    <IfFileName glob="*/*.log" />
                    <IfLastModified age="7d" />
                </Delete>
            </DefaultRolloverStrategy>
      </RollingFile>
      <!-- 产品数据分析日志 -->
        <RollingRandomAccessFile name="ProductLog"  
         fileName="${LOG_HOME}/${SERVER_NAME}.log"
         filePattern="${LOG_HOME}/back/${SERVER_NAME}.%d{yyyyMMddHHmmss}.log">
         <PatternLayout pattern="%d{yyyy.MM.dd HH:mm:ss.SSS} [%thread] %level [%C{36}.%M:%L] - %msg%xEx%n" />
            <Policies>
                <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
        </RollingRandomAccessFile>
   </appenders>

   <loggers>
      <logger name="org.slf4j" level="info" />
      <logger name="org.quartz" level="warn" />
      <logger name="org.redisson" level="info" />
      <logger name="com.atomikos" level="warn" />
      <logger name="com.alibaba.dubbo" level="info" />
      <logger name="org.apache.activemq" level="info" />
      <logger name="org.springframework" level="info" />
      <logger name="com.weibo.api.motan" level="warn" />
      <logger name="org.apache.zookeeper" level="warn" />
      <logger name="org.springframework.web" level="debug" />
      <Logger name="top.ibase4j" level="info">  
            <AppenderRef ref="ProductLog" />
        </Logger>
      <Logger name="org.ibase4j" level="debug">
            <AppenderRef ref="ProductLog" />
        </Logger>
      <Root level="debug">
         <AppenderRef ref="Console" />
         <AppenderRef ref="RollingFile" />
      </Root >
   </loggers>
</configuration>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值