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

x
?
Solved

Writing to the Event Viewer on Windows

Posted on 2006-06-16
11
Medium Priority
?
1,211 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
  • 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
Industry Leaders: 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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

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