LoggerService Class
A service that allows you to log server-side errors and events related to client-side reporting controls.
Namespace: DevExpress.XtraReports.Web.ClientControls
Assembly: DevExpress.XtraReports.v20.2.Web.dll
NuGet Package: DevExpress.Web.Reporting.Common
Declaration
Remarks
When you work with the client-side reporting controls (Web Document Viewer, Report Designer and Query Builder), you can use the LoggerService class to log server-side errors and events.
Tip
If you experience an issue with a Web Reporting application, the LoggerService helps you identify the cause of the issue. For more information on common issues and solutions, review the following help topic: Web Reporting - Troubleshooting.
The LoggerService.Error method allows you to process critical exceptions that are raised on the server side.
The LoggerService.Info method enables you to log document-related errors and information messages, such as “Document creation has been canceled”, “File ‘{0}’ was not deleted”, “The document creation has started” and so on.
Log Exceptions Only
If you need to log exceptions only, implement an action that processes them.
using System;
void ProcessException(Exception ex, string message) {
// Log exceptions here. For instance:
System.Diagnostics.Debug.WriteLine("[{0}]: Exception occured. Message: '{1}'. Exception Details:\r\n{2}",
DateTime.Now, message, ex);
}
Then, call the LoggerService.Initialize method overload that accepts this action at the application startup.
ASP.NET Web Forms and ASP.NET MVC
void Application_Start(object sender, EventArgs e) { // ... DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(ProcessException); }
ASP.NET Core
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // ... DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(ProcessException); }
Log Exceptions and Other Information
Implement a Custom Logger Service
If you also want to obtain information on other operations, create a custom logger service. Inherit your service from the LoggerService class and override the virtual LoggerService.Info and LoggerService.Error methods as shown below.
using System;
public class MyLoggerService : DevExpress.XtraReports.Web.ClientControls.LoggerService {
public override void Info(string message) {
System.Diagnostics.Debug.WriteLine("[{0}]: Info: '{1}'.", DateTime.Now, message);
}
public override void Error(Exception exception, string message) {
System.Diagnostics.Debug.WriteLine("[{0}]: Exception occured. Message: '{1}'. Exception Details:\r\n{2}",
DateTime.Now, message, exception);
}
}
Register a Custom Logger Service
To register a custom logger instance, use the LoggerService.Initialize method overload that accepts the logger object at application startup.
ASP.NET Web Forms and ASP.NET MVC
using System; void Application_Start(object sender, EventArgs e) { // ... DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(new MyLoggerService()); }
ASP.NET Core
using System; public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // ... DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(new MyLoggerService()); }