[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
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
Medium Priority
?
550 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Assisted Solution

by:ChloesDad
ChloesDad earned 400 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 83

Accepted Solution

by:
David Johnson, CD, MVP earned 1600 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 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