SreeN
SreeN

Reputation: 21

Reading event logs from Application and services logs using c# | PrintServices

Is there any way to fetch 'Application and Services logs' from event viewer by using c#? I could able to read the logs from windows logs but not from application and services logs. Exactly what i require is to read the log named 'Microsoft-Windows-PrintService/Operational'

Please suggest...!

Thanks in Adv.

Upvotes: 1

Views: 1612

Answers (2)

xmaxplx
xmaxplx

Reputation: 11

Try this:

string logType = "Microsoft-Windows-PrintService/Operational";
string query = "*[System/EventID=307]";

var elQuery = new 
    EventLogQuery(logType, PathType.LogName, query);
var elReader = new EventLogReader(elQuery);

for (EventRecord eventInstance = elReader.ReadEvent(); eventInstance != null; eventInstance = elReader.ReadEvent())
{
    //your code
}

Upvotes: 1

Roman Dibikhin
Roman Dibikhin

Reputation: 856

Use EventLog class with your custom log name. Read at MSDN for more.

Upvotes: 0

Related Questions