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

Declaration

public class LoggerService
Public Class LoggerService

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.

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 WebForms 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

If you need to additionally 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);
    }
}

To register a custom logger instance, use the LoggerService.Initialize method overload that accepts the logger object at the application startup.

  • ASP.NET WebForms 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());   
    }
    

Inheritance

Object
LoggerService
See Also