Solved

How t create a new event log for my Web application in Windows' event using code if it doesn't already exist?

Posted on 2015-01-09
2
499 Views
Last Modified: 2015-01-12
Hi, I'm using C# vs2012.
I'm using the example code here, https://support.microsoft.com/kb/307024/en-us?wa=wsignin1.0 
Can someone tell me what is sSource, sEvent and sLog referring to in the code?  What should I set them to basically.  

I want to have a log, let's say name "MyLog" to be created in Windows' Event viewer's "Application and Events logs", if that log doesn't exist already.

And also why the code below was called twice?  The 2nd time with additional parameters, it's odd.  Thank you.
EventLog.WriteEntry(sSource,sEvent);
                  EventLog.WriteEntry(sSource, sEvent,
0
Comment
Question by:lapucca
2 Comments
 
LVL 15

Assisted Solution

by:ChloesDad
ChloesDad earned 100 total points
ID: 40541519
They are text that will appear in the event log entry, you can set them to whatever you want.

The call is made twice to show how to use the different overloaded forms of the method, so that the programmer using the example will see how they are displayed differently in the event log.
0
 
LVL 79

Accepted Solution

by:
David Johnson, CD, MVP earned 400 total points
ID: 40541571
sSource=Myapp
sEvent="What happened"
sLog = "Application"
EventLogEntryType.Warning, 234);

Type can be Warning, Information, Error
234 is the event code of the error
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

832 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