禁用Log4J中的消息

时间:2013-12-26 12:20:35

标签: java log4j log4j2 log4

我有Log4J配置的这个例子。

Logger log = Logger.getRootLogger();
        BasicConfigurator.configure();  // Basic configuration for Log4J 1.x

        ConsoleAppender console = new ConsoleAppender(); //create appender
        //configure the appender
        console.setLayout(new PatternLayout("%d{dd/MM/yyyy HH:mm:ss} %m%n"));
        console.setThreshold(Level.DEBUG);
        console.activateOptions();
        //add appender to any Logger (here is root)
        Logger.getRootLogger().addAppender(console);

进入控制台,我得到了这个输出:

0 [FelixStartLevel] INFO root  - test____scs
26/12/2013 14:15:10 test____scs  

此消息0 [FelixStartLevel] INFO root - test____scs由代码Logger log = Logger.getRootLogger();打印如何禁用此代码?

1 个答案:

答案 0 :(得分:0)

试试这个

private static Logger logger = Logger.getLogger(CLASSNAME.class);

logger.info("WRITE YOUR MESSAGE"):