Solved

Writing to the Event Viewer on Windows

Posted on 2006-06-16
11
1,201 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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 300 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 54
even odd program using while loop 3 74
HashTable highest marks enumeration alternative 9 48
Cisco ASA: Java web start no go, asdm launcher no go 3 58
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
The viewer will learn how to implement Singleton Design Pattern in Java.

696 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