G
Ghost
I am trying to test log4j in HelloWorld to see if I can use it for my
logging.
Here is what I have:
//HelloWorld.java
import org.apache.log4j.*;
public class HelloWorld {
public static Logger logger = Logger.getLogger("HelloWorld");
public static void main(String[] args) {
logger.info("Entering main().");
System.out.println("Hello World!");
}
}
// This is my build.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="test" default="compile">
<property name="source.root" value="."/>
<property name="class.root" value="."/>
<property name="lib.dir" value="."/>
<property name="log4j.jar"
value="/export/home/bryan/dev/wui/WEB-INF/lib/log4j-1.2.9.jar"/>
<path id="project.class.path">
<pathelement location="${class.root}"/>
<pathelement location="${log4j.jar}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="compile" depends="clean">
<javac srcdir="${source.root}"
destdir="${class.root}"
debug="on"
deprecation="on"
source="1.4">
<classpath refid="project.class.path"/>
</javac>
</target>
</project>
I can get this to compile, but when I try to run it I get an error:
NoClassDefFoundError: org/apache/log4j/Logger
or
NoClassDefFoundError: org/apache/log4j/Category
Does anyone have any idea? I can get log4j to work with tomcat, but it
won't work with HelloWorld. I am using j2sdk1.4.2_08.
Any information would help.
Thanks in advance.
logging.
Here is what I have:
//HelloWorld.java
import org.apache.log4j.*;
public class HelloWorld {
public static Logger logger = Logger.getLogger("HelloWorld");
public static void main(String[] args) {
logger.info("Entering main().");
System.out.println("Hello World!");
}
}
// This is my build.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="test" default="compile">
<property name="source.root" value="."/>
<property name="class.root" value="."/>
<property name="lib.dir" value="."/>
<property name="log4j.jar"
value="/export/home/bryan/dev/wui/WEB-INF/lib/log4j-1.2.9.jar"/>
<path id="project.class.path">
<pathelement location="${class.root}"/>
<pathelement location="${log4j.jar}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="compile" depends="clean">
<javac srcdir="${source.root}"
destdir="${class.root}"
debug="on"
deprecation="on"
source="1.4">
<classpath refid="project.class.path"/>
</javac>
</target>
</project>
I can get this to compile, but when I try to run it I get an error:
NoClassDefFoundError: org/apache/log4j/Logger
or
NoClassDefFoundError: org/apache/log4j/Category
Does anyone have any idea? I can get log4j to work with tomcat, but it
won't work with HelloWorld. I am using j2sdk1.4.2_08.
Any information would help.
Thanks in advance.