Detailed log4j2 (bottom)-async/mongodb/flume Appender file output by log level

Source: Internet
Author: User
Tags mongodb
1. Differentiate file output by log level

Some people are accustomed to log information level output to different names of files, such as Info.log,error.log,warn.log, in the LOG4J2 can be configured by the filters to implement.

It is assumed that the information output to the Info.log,warn and error levels of info and the following levels is output to the error.log,fatal level to Fatal.log, and the configuration file is as follows:

[Java]  View plain  copy  print? <configuration status= "WARN"  monitorinterval= ">       < properties>           <property name= "LOG_HOME" >D:/logs</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= "Infofile"                  filename= "${log_home}/info.log"                 filepattern= "${log_home}/$${date:yyyy-mm}/info-%d{yyyy-mm-dd}-%i.log" >                <Filters>                    <thresholdfilter level= " Warn " onmatch=" DENY " onmismatch=" NEUTRAL " />                    <thresholdfilter level= "Trace"   Onmatch= "ACCEPT"  onmismatch= "DENY"  />                </Filters>                <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= " />           " </RollingRandomAccessFile>                       <rollingrandomaccessfile name= "ErrorFile"                 filename= "${log_home}/error.log"                 filepattern= "${log_home}/$${date:yyyy-mm}/error-%d{yyyy-mm-dd}-% I.log ">               <Filters>                     <thresholdfilter level= "Fatal"  onmatch= "DENY"  onmismatch= "NEUTRAL"  />                   < Thresholdfilter level= "Warn"  onmatch= "ACCEPT"  onmismatch= "DENY"  />                </Filters>                <patternlayout pattern= "%date{yyyy-MM-dd  hh:mm:ss. Sss} %level&nBsp [%thread] [%file:%line] - %msg%n]  />                <Policies>                    <TimeBasedTriggeringPolicy />                    <sizebasedtriggeringpolicy  size= "10&NBSP;MB"  />                </Policies>                <defaultrolloverstrategy max= " />         "   </RollingRandomAccessFile>                       <rollingrandomaccessfile name= "FatalFile"     &NBSP;            filename= "${LOG_HOME}/fatal.log"                 filepattern= "${LOG_HOME}/$${date : Yyyy-mm}/fatal-%d{yyyy-mm-dd}-%i.log ">                <Filters>                    <thresholdfilter level= "Fatal"  onmatch= "ACCEPT"   Onmismatch= "DENY"  />  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.