Multi-level filters

Source: Internet
Author: User

<Configuration>    <Appendername= "STDOUT"class= "Ch.qos.logback.core.ConsoleAppender">        <!--Encoders is assigned the type Ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -        <Encoder>            <pattern>%D{HH:MM:SS} [%thread]%-5level%logger{36}-%msg%n</pattern>        </Encoder>    </Appender>    <Loggername= "Cn.zno" Level= "WARN" />    <Root Level= "INFO">        <Appender-refref= "STDOUT" />    </Root></Configuration>

1. <logger name= "Cn.zno" level= "WARN"/>

The role is to configure the Logger class to intercept when A. Trace. Debug message is called.

class testlogback {    privatefinal Logger Logger = Loggerfactory.getlogger (getclass ());     publicvoid  Printlog () {        logger.trace ("It is Trace");        Logger.debug ("It is Debug");        Logger.info ("It is info");        Logger.warn ("It is warn");        Logger.error ("It is Error");}    }

Based on the following code in Ch.qos.logback.classic.Logger.class:

if (Effectivelevelint > level.levelint) {        return;      }

Effectivelevelint possible values are 5000, 10000, 20000, 30000, 40000

Corresponds to 5 levels: Trace, debug, info, warn, error

<logger name= "Cn.zno" level= "WARN"/> such as WARN value of 30000, greater than info debug trace, will only output WARN error

2. <root level= ""/>

Can only have one root, can be inherited by multiple appender, can affect the value of effectivelevelint, to <logger-based

If <root is considered a parent class, then <logger is the subclass

If the subclass does not specify this value, the parent class will prevail

If the child class specifies the value, the subclass is the subject of the

Multi-level filters

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.