C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Note: The Source must always be set. You can set this in the Properties panel if you do not want to assign the property in code.
PropertyTip: WriteEntry can be called in a variety of ways. The overloads that have more arguments will cause more data to be stored in the event log.
Also: The extra data should be used if it will be useful in diagnosing issues through the event logs.
C# program that uses EventLog
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
eventLog1.Source = "test";
eventLog1.WriteEntry("The Dev Codes article being written.");
eventLog1.WriteEntry("Please stand by while article continues.",
EventLogEntryType.Information);
eventLog1.WriteEntry("This website is being worked on.",
EventLogEntryType.Warning,
1000);
}
}
}
Tip: The event log can be located by browsing to Control Panel > System and Maintenance > Administrative Tools > View event logs.
Then: Click on Windows Logs > Application. These instructions apply to Windows Vista.
And: This can be beneficial to debugging software remotely—you can tell users to look through the event log.