Solved

How to write to Windows Event Log

Posted on 2003-11-16
7
518 Views
Last Modified: 2012-06-27
I write server-side applications in Java. These are frequently deployed on MS Windows servers. I'd like to be able to write errors to the MS Windows Event Log.

I have seen some code covering this through JNI, but it is pretty horrible. Has anyone any reasonable simple code - or a package - that does this?

(I have looked at
http://www.javaworld.com/javaworld/jw-09-2001/jw-0928-ntmessages.html? 
but it's fairly old and not very nice. I'm hoping for a better way. Is there an ActiveX I could call with Jawin, maybe?).

regards
Simon in Sydney, where the weather isn't as nice as it should be by now)
0
Comment
Question by:prcsn1
  • 4
  • 3
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 9761385
that solution looks about as good as you'll get.
(Calling an ActiveX component with Jawin is a lot messier in my opinion)

> where the weather isn't as nice as it should be by now

And its just started raining again :(
But as long as it's fine on the weekend for the wallabies I'm happy :-)
0
 
LVL 2

Author Comment

by:prcsn1
ID: 9761508
Sometimes - actually pretty often - I feel people go a long way out of their way to make things hard. (Actually, listening to my co-worker battling to get IIS/BizTalk, Certicates, Web Services to function together, I think these same people may be spending ALL of their time making things hard).

Ok. I'll try the suggested stuff.
Yuk. JNDI.

Actually I find base Jawin excellent. But the resouce stuff makes it a bit tricky.

Not too worried about the Wallabies - hey, I think I'll go sailing and have the Sydney Harbour to myself!
0
 
LVL 92

Expert Comment

by:objects
ID: 9761557
> Yuk. JNDI.

JNI actually. But all the works already done in the article so there's really not much left to be done. So you don't need to actually write any JNI yourself.

> Actually I find base Jawin excellent.

Yes jawin is nice, but it is just a JNI DLL providing a generic Java interface to Windows DLL. Whereas the code in the article provides a more focussed DLL for performing the task you require.

> I think I'll go sailing and have the Sydney Harbour to myself!

enjoy :-)
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 2

Author Comment

by:prcsn1
ID: 9761621
JNI, JNDI, let's call the whole thing off.

Currently battling to get it to work. It's resisting ...! It looks as though the C stuff has worked - but the Java side is resisting, dammit ... I've only been coding for 30 years, one day I'll get it right ... or maybe I should stick to sailing.
0
 
LVL 92

Expert Comment

by:objects
ID: 9761627
Whats the problem exactly?
0
 
LVL 2

Author Comment

by:prcsn1
ID: 9761650
Java doesn't want to run the class. It's usually some dopey problem with the classpath when this happens. But as I don't have one how can it be ... ah, got it. Needed a classpath of "."

Silly program ...


Ok I seem to have an output into the Event Viewer.

Hooray! About time too.

Great. Thanks for the encouragement - want to come sailing?
0
 
LVL 92

Expert Comment

by:objects
ID: 9761677
> want to come sailing?

Love to :-)


http://www.objects.com.au/staff/mick
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
rhino JavaScript import, load 25 82
Java SE 8u111  Lot of stuff broke 11 68
fibonacci ten numbers 4 38
How to determine if a string is a valid SHA value 7 28
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question