Using log4j, how I do logging to the Windows console?
How I do to the logging go to the Windows console (that black thing, CMD, COMMAND)? I'm trying with ConsoleAppender, but I don't if I doing it right.
private 开发者_如何学编程static ConsoleAppender appender = new ConsoleAppender(new PatternLayout());
private Logger database;
Log() {
BasicConfigurator.configure();
database = Logger.getLogger("DATABASE");
database.addAppender(appender);
}
EDIT:
first: this code is a sample, it is bigger than this second: on the console of Netbeans works perfectly.You need to setup all the appenders before logging information. Usually the setting up of log4j (including adding appenders) is done during startup of your application.
You should read the documentation here before trying anything more.
精彩评论