xtrareports-devexpress-dot-xtrareports-dot-web-dot-clientcontrols.md
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.v25.2.Web.dll
NuGet Package : DevExpress.Web.Reporting.Common
public class LoggerService
Public Class LoggerService
Note
The LoggerService is intended for use in ASP.NET Web Forms and ASP.NET MVC applications.
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.
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.
Applications with Blazor JS-Based reporting controls (Server and Wasm) and ASP.NET Core apps use built-in logging. You can configure logging for the DevExpress category as described in the Configure logging section of the following article: Logging in .NET Core and ASP.NET Core. If you use built-in logging, the LoggerService is redundant.
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);
}
Imports System
Private Sub ProcessException(ex As Exception, message As String)
' Log exceptions here. For instance:
System.Diagnostics.Debug.WriteLine("[{0}]: Exception occured. Message: '{1}'. Exception Details:"
& ControlChars.CrLf & "{2}", Date.Now, message, ex)
End Sub
Then, call the LoggerService.Initialize method overload that accepts this action at the application startup.
void Application_Start(object sender, EventArgs e) {
// ...
DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(ProcessException);
}
Private Sub Application_Start(sender As Object, e As EventArgs)
' ...
DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(AddressOf ProcessException)
End Sub
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);
}
}
Imports System
Public Class MyLoggerService
Inherits DevExpress.XtraReports.Web.ClientControls.LoggerService
Public Overrides Sub Info(message As String)
System.Diagnostics.Debug.WriteLine("[{0}]: Info: '{1}'.", Date.Now, message)
End Sub
Public Overrides Sub [Error](exception As Exception, message As String)
System.Diagnostics.Debug.WriteLine("[{0}]: Exception occured. Message: '{1}'. Exception Details:"
& ControlChars.CrLf & "{2}", Date.Now, message, exception)
End Sub
End Class
To register a custom logger instance, use the LoggerService.Initialize method overload that accepts the logger object at application startup.
using System;
void Application_Start(object sender, EventArgs e) {
// ...
DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(new MyLoggerService());
}
Imports System
Private Sub Application_Start(sender As Object, e As EventArgs)
' ...
DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(New MyLoggerService())
End Sub
Object LoggerService
See Also