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
534 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 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 81

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

696 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