Log4j help with NT Appender
Hi there
I have relatively new to Java so I am hoping that someone can help me.
I'm trying to use the NTEventLogAppender class to write to the windows
event log. However, my program terminates as soon as it hits the
declaration for the appender object.
here is some sample code which demo's the problem:
import org.apache.log4j.*;
import org.apache.log4j.nt.NTEventLogAppender;
public class HelloWorld {
// method main(): ALWAYS the APPLICATION entry point
public static void main (String[] args) {
NTEventLogAppender eventLogAppender = new NTEventLogAppender();
System.out.println ("Hello World!");
}
}
So I can compile the above using the following command:
javac -cp log4j.jar HeloWorld.java
But when I run the program I get the following error:
java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/
log4j/nt/N
TEventLogAppender
at HelloWorld.main(HelloWorld.java:10)
Caused by: java.lang.ClassNotFoundException:
org.apache.log4j.nt.NTEventLogAppen
der
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 1 more
The NTEventLogAppender is included in the log4j jar file so I have
really no idea why it won't work. I would really appreciate some help
on this :)
Eddie