Solved

How to write to Windows Event Log

Posted on 2003-11-16
7
516 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

910 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

19 Experts available now in Live!

Get 1:1 Help Now