문제

I want to initialize a logger to simply write to the console.

E.g. (incorrect code)

Logger logger = Logger.getLogger(System.out);
logger.debug("test") //prints to System.out
도움이 되었습니까?

해결책

You can add a ConsoleAppender to the logger at Runtime. The following link details this: http://howtodoinjava.com/2013/04/08/how-to-programmatically-configure-appenders-in-log4j/

다른 팁

If you are using Apachi Logger or Java util logger then you should need to know this that getLogger() method is not taking any class object as argument.

Apachi Logger for print on console - See Console Appender.

Java Util Logger

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top