Solved

How to write to Windows Event Log

Posted on 2003-11-16
7
512 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
Comment Utility
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
Comment Utility
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
Comment Utility
> 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:prcsn1
Comment Utility
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
Comment Utility
Whats the problem exactly?
0
 
LVL 2

Author Comment

by:prcsn1
Comment Utility
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
Comment Utility
> want to come sailing?

Love to :-)


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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now