0
votes

I have this example of Log4J configuration.

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);

Into the console I get this output:

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

This message 0 [FelixStartLevel] INFO root - test____scs is printed by the code Logger log = Logger.getRootLogger(); How i can disable this code?

1
simply comment this line Logger.getRootLogger().addAppender(console); - KhAn SaAb
Yes but I want to print the messages 26/12/2013 14:15:10 test____scs - user3136666
comment this line console.activateOptions(); and run it see the output. - KhAn SaAb
I get this 0 [FelixStartLevel] INFO root - test____scs log4j:ERROR No output stream or file set for the appender named [null]. - user3136666

1 Answers

0
votes

try this

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

logger.info("WRITE YOUR MESSAGE"):