Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Writing to the Event Viewer on Windows

Posted on 2006-06-16
11
Medium Priority
?
1,208 Views
Last Modified: 2008-02-01
Hey guys,

Could someone please details the steps involved in writing to the Event Viewer from a java application

Cheers,
Una
0
Comment
Question by:mcgettiu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 16921022
You will probably need to use native code for that. Write a C++ function to do that and call it from Java using JNI:

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html (JNI tutorial)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16921041
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16921046
This is an article which details the steps to do it using JNI:

http://www.javaworld.com/javaworld/jw-09-2001/jw-0928-ntmessages.html
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:DeanHorak
ID: 16921210
mayankeagle is correct, you'll need to create a C++ function and call it using JNI.

To write to the event log (and be able to view it in the event viewer), you'll need to use the System::Diagnostics::EventLog class.

i.e.

System::Diagnostics::EventLog* log = new System::Diagnostics::EventLog();
log->Source= S"MyAppName";
log->WriteEntry(S"My Log Message",System::Diagnostics::EventLogEntryType::Information); // Can be Information,Warning or Error

Hope this helps...
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1200 total points
ID: 16922388
0
 
LVL 11

Expert Comment

by:DeanHorak
ID: 16923195
Nice one CEHJ...

mcgettiu - CEHJ's suggestion is definitely the way to go on this one
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 16926822
Thanks. As one of the authors of NTEventLogAppender I always feel the most satisfaction when others appreciate my work. I CEHJ hadn't beat me (welcome back BTW) that was going to be my response also.
:-)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16929695
>> As one of the authors of NTEventLogAppender

That's great~!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16929737
>>welcome back BTW

Thanks Jim
0
 

Author Comment

by:mcgettiu
ID: 16934209
Hi guys,

Thanks for all the responses....it will take me a few days to go through the stuff and allocated points fairly....

But thanks again
mcgettiu
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16934287
:-)
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

722 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