Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Log4j help with NT Appender

76 views
Skip to first unread message

Eddie Grogan

unread,
Jan 2, 2012, 10:09:31 AM1/2/12
to

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

Jeff Higgins

unread,
Jan 2, 2012, 10:30:39 AM1/2/12
to
On 01/02/2012 10:09 AM, Eddie Grogan wrote:
>
> 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

<http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html>

Jeff Higgins

unread,
Jan 2, 2012, 10:38:22 AM1/2/12
to
On 01/02/2012 10:30 AM, Jeff Higgins wrote:
> On 01/02/2012 10:09 AM, Eddie Grogan wrote:
>>
>> Hi there

>> 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
>
> <http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html>
>
>
Please note also this easy to navigate link into a large chunk of
Oracle's Java Platform documentation.
<http://docs.oracle.com/javase/7/docs/index.html>

John B. Matthews

unread,
Jan 2, 2012, 11:47:24 AM1/2/12
to
In article <jdsimr$6a3$1...@dont-email.me>,
Jeff Higgins <je...@invalid.invalid> wrote:

> Please note also this easy to navigate link into a large chunk of
> Oracle's Java Platform documentation.

> <http://docs.oracle.com/javase/7/docs/index.html>

Excellent. There's a convenient temporal axis, too:

<http://docs.oracle.com/javase/6/docs/index.html>
<http://docs.oracle.com/javase/5/docs/index.html>
<http://docs.oracle.com/javase/4/docs/index.html>
<http://docs.oracle.com/javase/3/docs/index.html>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Lew

unread,
Jan 2, 2012, 12:18:06 PM1/2/12
to
On Monday, January 2, 2012 7:30:39 AM UTC-8, Jeff Higgins wrote:
> On 01/02/2012 10:09 AM, Eddie Grogan wrote:
>> 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.
>> ... [snip] ...
>> But when I run the program I get the following error:
>> java HelloWorld

You left off the classpath.

> <http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html>
>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/log4j/nt/NTEventLogAppender
>> at HelloWorld.main(HelloWorld.java:10)
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.log4j.nt.NTEventLogAppender
>> ... [snip] ...
>> The NTEventLogAppender is included in the log4j jar file so I have
>> really no idea why it won't work.

The JAR does no good if it's not in the classpath.

--
Lew
0 new messages