Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.2.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

#Declaration

public class LoggerService

#Remarks

#ASP.NET Web Forms and ASP.NET MVC

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.

#Blazor JS-Based Reporting (Server and Wasm) and ASP.NET Core

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.

#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.

void Application_Start(object sender, EventArgs e) {
    // ... 
    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.

using System;

void Application_Start(object sender, EventArgs e) {
    // ... 
    DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(new MyLoggerService());
}

#Inheritance

Object
LoggerService
See Also