//////这一行是错误提到的16行
private static Logger logger = Logger.getLogger(filter.class);
//////下面是错误提示信息
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/message/Message
at test.filter.<clinit>(filter.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.message.Message
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
////////完整的代码如下
package test;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.log4j.Logger;
/**
* 删除无用的URL,用于在数据库抽取数据后
*
*/
public class filter {
private static Logger logger = Logger.getLogger(filter.class);
public static void queryActiveUserID(int activeDayCount) throws IOException {
String resultFileName = "result";
char[] ch = {'a','s','d'};
FileWriter fileWriter = new FileWriter(
resultFileName, true);
fileWriter.write(ch);
fileWriter.close();
System.out.println("over!");
}
public static void main(String args[]) throws IOException{
logger.debug("This is debug message.");
filter.queryActiveUserID(0);
}
}
------解决方案--------------------
log4j的jar包没导入
------解决方案--------------------
log4j-1.2-api-2.0-rc1.jar log4j-core-2.0-rc1.jar 这两个包版本不一致,一个1.2,一个2.0。
------解决方案--------------------
我表示把你的代码copy一份,然后自己新建一个工程导入,没问题啊
[main] DEBUG com.zhaowei.test.filter - This is debug message.
over!
只需要导入一个jar
log4j.jar