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
505 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 80

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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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