如何让SLF4J“Hello World”与log4j一起工作?
SLF4J的“Hello World”示例对我不起作用。我想这是因为我在类路径中添加了slf4j-log4。我应该直接配置log4j以使hello世界正常工作吗?
log4j:WARN No appenders could be found for logger (HelloWorld).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
更新:我添加了log4j初始化,但它仍然不起作用:
public static void main(String[] params) {
org.apache.log4j.Logger.getRootLogger().addAppender(new ConsoleAppender());
Logger logger = org.slf4j.LoggerFactory.getLogger(TestBase.class);
logger.info("Hello World");
}
我得到:
log4j:ERROR No output stream or file set for the appender named [null].