添加记录器以将其从控制台中排除

时间:2017-09-15 11:34:24

标签: xml log4j2

我从Ireport 5.5迁移到Studio 6.4 libs,我开始看到一些新闻DEBUG和TRACE日志,我决定将它们排除在外

Información:   2017-09-15 08:14:09,920 TRACE beanutils.MethodUtils [] - Matching name=addElement on class net.sf.jasperreports.engine.design.JRDesignBand
Información:   2017-09-15 08:14:09,921 DEBUG digester.Digester [] -   Fire end() for FactoryCreateRule[className=net.sf.jasperreports.engine.xml.JRTextFieldFactory, attributeName=null, creationFactory=net.sf.jasperreports.engine.xml.JRTextFieldFactory@58abbf35]
Información:   2017-09-15 08:14:09,921 DEBUG digester.Digester [] - [FactoryCreateRule]{jasperReport/pageFooter/band/textField} Pop net.sf.jasperreports.engine.design.JRDesignTextField
Información:   2017-09-15 08:14:09,922 DEBUG Digester.sax [] - ignorableWhitespace(     )
Información:   2017-09-15 08:14:09,922 DEBUG Digester.sax [] - endElement(http://jasperreports.sourceforge.net/jasperreports,band,band)

所以我添加到我的 log4j2.xml 记录器名称="消化器",但它无法正常工作,我一直在控制台中看到日志

 <Loggers>
        <Logger name="org.hibernate" level ="warn"></Logger>
----->  <Logger name="digester" level="warn"></Logger> <-------!!!!!!
        <Logger name="net.sf.jasperreports" level="info"></Logger>
        <Logger name="org.apache.commons.beanutils.converters" level="warn"></Logger>
        <Logger name="com.mchange" level="info"></Logger>
        <Root level="all">
            <AppenderRef ref="console"/>
            <AppenderRef ref="logfile" level="error"/>
        </Root>
    </Loggers>

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我忘了我已经为追加器%c {2} 配置了“精度”: org.apache.commons.digester

<Console name="console" target="System.out">
            <RegexFilter regex=".*(Javassist Enhancement failed|could not create proxy factory for).*" onMatch="DENY" onMismatch="ACCEPT"/>
            <PatternLayout pattern="%d %-2p %c{2} %x - %m%n"/> 
</Console>

正因为如此,我没有看到我必须添加到Logger中的已完成的包才能正常工作

<强>