
Accessing SSRS log programmatically?
1 Expert Answer
Rize S. answered 03/23/23
Senior IT Certified Trainer, IT Developer & DBA Administrator
Yes, it is possible to access SSRS logs programmatically using the ReportingServicesLog class in the Microsoft.ReportingServices.Diagnostics namespace.
You can add a reference to the Microsoft.ReportingServices.Diagnostics.dll assembly in your project and use the following code to access the SSRS logs:
using Microsoft.ReportingServices.Diagnostics;
// Create a ReportingServicesLog instance
ReportingServicesLog log = new ReportingServicesLog();
// Set the log level (optional)
log.CurrentLogLevel = LogLevel.Verbose;
// Get the log entries for a specific time period
DateTime startTime = DateTime.Now.AddDays(-1);
DateTime endTime = DateTime.Now;
LogEntryCollection entries = log.ReadLog(startTime, endTime);
// Iterate over the log entries
foreach (LogEntry entry in entries)
{
// Do something with the log entry
}
The above code will retrieve log entries for the last day with a verbose level of logging. You can adjust the log level and time period according to your requirements.
Note that you may need to have appropriate permissions to access the SSRS logs.
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
John C.
The simple answer to the last part of your question is "of course; just trap the exception and log it." I wonder if your question needs some revision so someone could provide a more concise answer to it.01/11/21