• log4j


    properties 配置

    # root LOGGER (default logger). That means when no name specified/name cannot found when calling Logger.getLogger("any name"), would default call root logger.
    # root LOGGER include two APPENDER (not LOGGER), which are APPENDER "file" and "admin"
    log4j.rootLogger=INFO, file, admin
    
    #define a new LOGGER named "file", which include "file" APPENDER
    log4j.logger.file=DEBUG, fileAppender
    
    #define a new LOGGER named "admin", which include "admin" APPENDER
    log4j.logger.admin=DEBUG, adminAppender
    
    #set "additivity" attribute for LOGGER "file" and "admin"
    log4j.additivity.file=false
    log4j.additivity.admin=false
    
    #define a APPENDER which name is "file"
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.File=/home/nick/logging/file.log
    log4j.appender.file.MaxFileSize=1MB
    log4j.appender.file.MaxBackupIndex=1
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n
    
    #define a APPENDER which name is "admin"
    log4j.appender.admin=org.apache.log4j.RollingFileAppender
    log4j.appender.admin.File=/home/nick/logging/admin.log
    log4j.appender.admin.MaxFileSize=1MB
    log4j.appender.admin.MaxBackupIndex=1
    log4j.appender.admin.layout=org.apache.log4j.PatternLayout
    log4j.appender.admin.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n

    XML 配置

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration><!--xmlns:log4j="http://jakarta.apache.org/log4j/"-->
    
        <!--
        #define a APPENDER which name is "stdout"
        -->
        <appender class="org.apache.log4j.ConsoleAppender" name="stdout">
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="[%d] [%X{hostname}] [%X{status}] [%t] %p %c{2} %m%n"/>
            </layout>
        </appender>
    
        <!--
        #define a APPENDER which name is "rollingFile"
        -->
        <appender name="rollingFile" class="org.apache.log4j.appender.TimeAndSizeRollingAppender">
            <param name="File" value="logs/${engine}plengine.log"/>
            <param name="DatePattern" value=".yyyy-MM-dd"/>
            <param name="MaxFileSize" value="50MB"/>
            <param name="DateRollEnforced" value="true"/>
            <param name="MaxRollFileCount" value="100"/>
            <param name="BufferedIO" value="false"/>
            <param name="RollOnStartup" value="true"/>
            <param name="CompressionAlgorithm" value="ZIP"/>
            <param name="CompressionMinQueueSize" value="3"/>
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="[%d] [%X{hostname}] [%X{status}] [%t] [%p] %c{2} %m%n"/>
            </layout>
        </appender>
    
        <!--
        #define a APPENDER which name is "rollingMonikerFile"
        -->
        <appender name="rollingMonikerFile" class="org.apache.log4j.appender.TimeAndSizeRollingAppender">
            <param name="File" value="logs/${engine}plengine-Moniker.log"/>
            <param name="DatePattern" value=".yyyy-MM-dd"/>
            <param name="MaxFileSize" value="50MB"/>
            <param name="DateRollEnforced" value="true"/>
            <param name="MaxRollFileCount" value="100"/>
            <param name="BufferedIO" value="false"/>
            <param name="RollOnStartup" value="true"/>
            <param name="CompressionAlgorithm" value="ZIP"/>
            <param name="CompressionMinQueueSize" value="3"/>
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="[%d] [%X{hostname}] [%X{status}] [%t] [%p] %c{2} %m%n"/>
            </layout>
        </appender>
    
        <!--
        #define a new LOGGER named "MonikerLogger", which include "rollingMonikerFile" APPENDER
        -->
        <logger name="MonikerLogger" additivity="false">
            <level value="INFO"/>
            <appender-ref ref="rollingMonikerFile" />
        </logger>
    
        <!--
        # root LOGGER (default logger). That means when no name specified/name cannot found when calling Logger.getLogger("any name"), would default call root logger.
        # root LOGGER include two APPENDER (not LOGGER), which are "stdout" and "rollingFile"
        -->
        <root>
            <level value="INFO"/>
            <appender-ref ref="stdout" />
            <appender-ref ref="rollingFile"/>
        </root>
    
    </log4j:configuration>

    Mapping关系

  • 相关阅读:
    02梦断代码阅读笔记之二
    每日日报
    每日日报
    每日日报
    每日日报
    02梦断代码阅读笔记之一
    每日日报
    SQL语句分为哪几种?
    数据库三范式是什么?
    什么是数据库事务?
  • 原文地址:https://www.cnblogs.com/frankcui/p/12707073.html
Copyright © 2020-2023  润新知