log4j配置

properties配置
#production release
log4j.rootLogger = info, stdout, F, error

log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [DUBBO-RESV-EXN] %d{yy/MM/dd HH:mm:ss:sss z} [%t] %c %L %p: %m%n

log4j.appender.F = org.apache.log4j.DailyRollingFileAppender
log4j.appender.F.File = /usr/local/logs/test_default.log
log4j.appender.F.layout = org.apache.log4j.PatternLayout
log4j.appender.F.Threshold = INFO
log4j.appender.F.DatePattern = '_'yyyy-MM-dd'.log'
log4j.appender.F.layout.ConversionPattern = [DUBBO-RESV-EXN] %d{yy/MM/dd HH:mm:ss:sss z} [%t] %c %L %p: %m%n

log4j.logger.error=error
log4j.appender.error = org.apache.log4j.DailyRollingFileAppender
log4j.appender.error.File = /usr/local/logs/test_error.log
log4j.appender.error.layout = org.apache.log4j.PatternLayout
log4j.appender.error.Threshold = ERROR
log4j.appender.error.DatePattern = '_'yyyy-MM-dd'.log'
log4j.appender.error.layout.ConversionPattern = [DUBBO-RESV-EXN] %d{yy/MM/dd HH:mm:ss:sss z} [%t] %c %L %p: %m%n

XML 配置如下:
<?xml version="1.0" encoding="UTF-8" ?>

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://jakarta.apache.org/log4j/">

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c.%M | %m%n"/>
        </layout>
    </appender>

    <appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="file" value="/usr/local/logs/test.log"/>
        <param name="Append" value="true" />
        <param name="DatePattern" value="'.'yyyy-MM-dd" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c.%M | %m%n"/>
        </layout>
    </appender>

    <logger name="com.test.ccc">
        <level value="debug"/>
    </logger>

    <logger name="org.springframework.ws.client.MessageTracing">
        <level value="trace"/>
    </logger>
    <logger name="org.springframework.ws.server.MessageTracing">
        <level value="trace"/>
    </logger>

    <root>
        <priority value="info"/>
        <appender-ref ref="console"/>
        <appender-ref ref="file"/>
    </root>

</log4j:configuration>

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值