Solved

Writing to the Event Viewer on Windows

Posted on 2006-06-16
11
1,194 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:mayankeagle
Comment Utility
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:mayankeagle
Comment Utility
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
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
 
LVL 11

Expert Comment

by:DeanHorak
Comment Utility
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
Comment Utility
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 11

Expert Comment

by:DeanHorak
Comment Utility
Nice one CEHJ...

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

Expert Comment

by:Jim Cakalic
Comment Utility
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:mayankeagle
Comment Utility
>> As one of the authors of NTEventLogAppender

That's great~!
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>welcome back BTW

Thanks Jim
0
 

Author Comment

by:mcgettiu
Comment Utility
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
Comment Utility
:-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

762 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

9 Experts available now in Live!

Get 1:1 Help Now