-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventLog.cs
More file actions
49 lines (47 loc) · 1.07 KB
/
eventLog.cs
File metadata and controls
49 lines (47 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Diagnostics;
namespace CCMClient
{
/// <summary>
/// Summary description for eventLog.
/// </summary>
public class eventLog
{
public string listLogs()
{
String retVal = "";
EventLog[] ea = EventLog.GetEventLogs(".");
for (int i=0; i < ea.Length; i++)
retVal += " [" + ea[i].Log + "] ";
return retVal;
}
public string viewLog(string log,int maxNum)
{
String retVal = "";
//if(EventLog.SourceExists(log))
try
{
EventLog aLog = new EventLog();
aLog.Log = log;
aLog.MachineName = ".";
//foreach (EventLogEntry entry in aLog.Entries)
EventLogEntry entry;
for(int i=aLog.Entries.Count-1;(i>0 && (i > aLog.Entries.Count-1 - maxNum));i--)
{
entry = aLog.Entries[i];
retVal += " " + entry.TimeGenerated.ToString().Replace(":","#C#") + ": " + entry.EntryType + " - " + entry.Source + "\n" + entry.Message+"\n";
}
aLog.Close();
}
catch (Exception e){
}
return retVal;
}
public eventLog()
{
//
// TODO: Add constructor logic here
//
}
}
}