using System;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
namespace EventUtils
{
class EventViewer
{
static void Main(string[] args)
{
string megString = "Product: MySQL Tools for 5.0";
/* Create an object for event log */
EventLog elog = new EventLog();
/* Tell Which type of log we need to access
1. System
2. Security
3. Application
*/
elog.Log = "Application";
//Filter and Select Eventlog Entries Using LINQ
var ev = from EventLogEntry e in elog.Entries where e.Source == "MsiInstaller" && e.Message.Contains(megString) select e;
foreach (var eventEntity in ev)
{
Console.WriteLine("Message: " + eventEntity.Message + "\n" +
"App: " + eventEntity.Source + "\n" +
"Entry type: " + eventEntity.EntryType + "\n" +
"User Name: " + eventEntity.UserName);
Console.WriteLine();
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment