zoukankan      html  css  js  c++  java
  • log4j配置不同的类多个日志文件

    <Configuration status="INFO">
    <Appenders>
    <Console name="STDOUT" target="SYSTEM_OUT">
    <PatternLayout pattern="[%-5p %d{yyyy-MM-dd HH:mm:ss,SSS}] %m%n"/>
    </Console>
    <RollingFile name="LOG-MAIN" fileName="${logpath}/main.log"
    filePattern="${logpath}/main-%d{yyyy-MM-dd}.log">
    <PatternLayout
    pattern="[%-5p %d{yyyy-MM-dd HH:mm:ss,SSS}] %m%n"/>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true" />
    </Policies>
    <ThresholdFilter level="INFO"/>
    </RollingFile>
    <RollingFile name="LOG-DNHANDLER" fileName="${logpath}/dnHandler.log"
    filePattern="${logpath}/server-%d{yyyy-MM-dd}.log">
    <PatternLayout
    pattern="[%-5p %d{yyyy-MM-dd HH:mm:ss,SSS}] %m%n"/>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true" />
    </Policies>
    <ThresholdFilter level="INFO"/>
    </RollingFile>
    <RollingFile name="LOG-CIDR4DNSLOADER" fileName="${logpath}/cidr4DNSLoader.log"
    filePattern="${logpath}/server-%d{yyyy-MM-dd}.log">
    <PatternLayout
    pattern="[%-5p %d{yyyy-MM-dd HH:mm:ss,SSS}] %m%n"/>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true" />
    </Policies>
    <ThresholdFilter level="INFO"/>
    </RollingFile>
    <RollingFile name="LOG-DNSERVICEIMPL" fileName="${logpath}/dnServiceImpl.log"
    filePattern="${logpath}/server-%d{yyyy-MM-dd}.log">
    <PatternLayout
    pattern="[%-5p %d{yyyy-MM-dd HH:mm:ss,SSS}] %m%n"/>
    <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true" />
    </Policies>
    <ThresholdFilter level="INFO"/>
    </RollingFile>
    </Appenders>

    <Loggers>
    <Root level="${loglevel}">
    <AppenderRef ref="STDOUT"/>
    <AppenderRef ref="LOG-MAIN"/>
    </Root>
    <logger name="com.vh.app.pat.httpdns.handler.DnHandler" level="${loglevel}" additivity="false">
    <AppenderRef ref="LOG-DNHANDLER"/>
    </logger>
    <logger name="com.vh.app.pat.httpdns.data.Cidr4DNSLoader" level="${loglevel}" additivity="false">
    <AppenderRef ref="LOG-CIDR4DNSLOADER"/>
    </logger>
    <logger name="com.vh.app.pat.httpdns.service.imp.DnServiceImpl" level="${loglevel}" additivity="false">
    <AppenderRef ref="LOG-DNSERVICEIMPL"/>
    </logger>
    </Loggers>
    </Configuration>

    类似的在property文件里面配置

    参考:http://blog.sina.com.cn/s/blog_4521e7ac0101g3tz.html

  • 相关阅读:
    SQLServer 备份和还原
    Ling To DataTable
    asp.net安全防范
    SQLServer 定时备份(一)
    asp.net网站安全常见问题与防范
    SQLServer 定时备份(二)
    flex大法:一网打尽所有常见布局
    BetterScroll源码阅读顺便学习TypeScript
    快速搭建一个代码在线编辑预览工具
    一个简单标注库的插件化开发实践
  • 原文地址:https://www.cnblogs.com/gstsyyb/p/5669449.html
Copyright © 2011-2022 走看看