• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1217
  • Last Modified:

Writing to the Event Viewer on Windows

Hey guys,

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

Cheers,
Una
0
mcgettiu
Asked:
mcgettiu
  • 4
  • 3
  • 2
  • +2
1 Solution
 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
0
 
Mayank SAssociate Director - Product EngineeringCommented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
DeanHorakCommented:
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
 
DeanHorakCommented:
Nice one CEHJ...

mcgettiu - CEHJ's suggestion is definitely the way to go on this one
0
 
Jim CakalicSenior Developer/ArchitectCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> As one of the authors of NTEventLogAppender

That's great~!
0
 
CEHJCommented:
>>welcome back BTW

Thanks Jim
0
 
mcgettiuAuthor Commented:
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
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now