Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1498

Re: Log4j help with NT Appender

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.help
Subject Re: Log4j help with NT Appender
Date 2012-01-02 10:30 -0500
Organization A noiseless patient Spider
Message-ID <jdsi7m$33t$1@dont-email.me> (permalink)
References <0d4b8e35-b28d-4e28-81c5-bf437974930e@z12g2000yqm.googlegroups.com>

Show all headers | View raw


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>

>
> 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

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Log4j help with NT Appender Eddie Grogan <eddiegrogan@googlemail.com> - 2012-01-02 07:09 -0800
  Re: Log4j help with NT Appender Jeff Higgins <jeff@invalid.invalid> - 2012-01-02 10:30 -0500
    Re: Log4j help with NT Appender Jeff Higgins <jeff@invalid.invalid> - 2012-01-02 10:38 -0500
      Re: Log4j help with NT Appender "John B. Matthews" <nospam@nospam.invalid> - 2012-01-02 11:47 -0500
    Re: Log4j help with NT Appender Lew <lewbloch@gmail.com> - 2012-01-02 09:18 -0800

csiph-web