Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to write to Windows Event Log

Posted on 2003-11-16
7
Medium Priority
?
537 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 750 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses

824 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