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
471 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 78

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

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

18 Experts available now in Live!

Get 1:1 Help Now