Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Diagnostics;
- using System.IO;
- namespace BTLA
- {
- class Program
- {
- static void Main(string[] args)
- {
- string location = args[0];
- string x = args[1];
- string entryType = args[3];
- int timeFrame = int.Parse(x);
- StringBuilder sb = new StringBuilder();
- string logType = args[2];
- //string entryType = "Information";
- EventLog ev = new EventLog(logType, Environment.MachineName);
- int LastLogToShow = ev.Entries.Count;
- if (LastLogToShow <= 0)
- Console.WriteLine("No Event Logs in Log: " + logType);
- foreach (EventLogEntry e in ev.Entries)
- {
- if (e.EntryType.ToString() == entryType)
- {
- if (e.TimeGenerated > DateTime.Today.AddDays(-timeFrame))
- {
- sb.AppendLine("Event ID2: " + e.InstanceId);
- Console.WriteLine(e.InstanceId);
- sb.AppendLine("Entry Type: " + e.EntryType.ToString());
- sb.AppendLine("Message: " + e.Message + "\n");
- sb.AppendLine(e.TimeGenerated.ToString());
- sb.AppendLine("-------------------------------------------------------------------------");
- Console.WriteLine(e);
- }
- }
- }
- if (location != null)
- {
- Directory.CreateDirectory(location);
- Write(location);
- }
- ev.Close();
- Console.ReadLine();
- }
- static void Write(string location)
- {
- StringBuilder sb = new StringBuilder();
- using (StreamWriter sw = new StreamWriter(location + "\\BTLA Log.txt"))
- {
- sw.Write(sb.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement