我知道这可能是一个新手问题,但我在设置 Log4J 时遇到了问题:
我想运行一个 log4j 演示,这是我的代码:
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
public class HelloLOG4j {
private static final Logger logger = Logger.getLogger(Hello.class);
public static void main(String argv[]) {
BasicConfigurator.configure();
logger.debug("Hello world.");
logger.info("What a beatiful day.");
}
}
我在 System 和 User var 中设置了我的 Classpath: C:\Users\Adel\Downloads\apache-log4j-1.2.17\log4j-1.2.17.jar
但是当我运行我的程序时,我仍然得到
errors found:
File: C:\Users\Adel\Desktop\various_topics\JavaProjects\HelloLOG4j.java [line: 2]
Error: package org.apache.log4j does not exist
我知道我设置了正确的类路径 - 如果我运行 cmd 行:
C:\Program Files\Java\jdk1.6.0_20>print %LOG4J_HOME%
C:\Users\Adel\Downloads\apache-log4j-1.2.17\log4j-1.2.17.jar is currently bein
g printed