第三方包路径
D:\jp\log4j\log4j-1.2.16.jar
代码D:\jp\log4j\Log4jDemo.java
import org.apache.log4j.*;public class Log4jDemo{ //参数与所在类名一致 private static Logger logger = Logger.getLogger(Log4jDemo.class); public static void main(String[] args) { //初始化,使用默认配置 BasicConfigurator.configure(); logger.debug("This is a test log."); } }编译
javac -classpath ".\*" Log4jDemo.java
执行
java -classpath ".;.\*" Log4jDemo
输出
0 [main] DEBUG Log4jDemo - This is a test log.