Log In
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
  [Expand]Application Solution Components
   Client-Side Mobile Application
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]UI Construction
  [Expand]Extend Functionality
  [Expand]Data Manipulation and Business Logic
  [Expand]Security System
  [Expand]System Module
  [Expand]Extra Modules
  [Collapse]Debugging, Testing and Error Handling
    Log Files
    Collect and Analyze the Diagnostic Information
    Add Custom Log Entries and Customize the Default Tracer Behavior
    Error Handling in ASP.NET and Mobile Applications
   [Expand]Functional Testing
  [Expand]Application Life Cycle
 [Expand]Design-Time Features
 [Expand]Task-Based Help
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Add Custom Log Entries and Customize the Default Tracer Behavior

This topic describes the API you can use to add information to XAF log files from your code. The DevExpress.Persistent.Base.Tracing class is used for this purpose.

The Tracing class does not store log strings internally. It passes all strings to the Trace.WriteLine method.

You can access the Tracing instance using the Tracing.Tracer static property and then call one of its methods.

Expanded Tracing Methods

The following table list the most important methods of the Tracing class.

Method Logged Information Sample Result
LogText(string text) The text passed as the method's parameter
06.09.16 11:58:10.739  Text
LogValue(string valueName, object objectValue) The caption and value passed as parameters, delimited by colon.
06.09.16 11:58:10.739  ValueName: ObjectValue
LogSeparator(string comment) The text passed as the method's parameter, and a separator under it.
06.09.16 11:58:10.739 Comment
06.09.06 11:58:10.739 ====================
LogSubSeparator(string comment) The separator and then the text passed as the value parameter.
06.09.16 11:58:10.739 --------------
06.09.06 11:58:10.739 Comment
LogError(Exception exception) The type and message of the specified exception, followed by the stack trace.
The error that occurred
    Type: Exception type
    Message: Exception message
Stack trace: ...

Expanded Custom Tracing

You can inherit the Tracing class and override its virtual methods to implement custom logging.

The Tracing.CreateCustomTracer static event occurs each time a Tracing instance is created. Handle this event to replace the default Tracing instance with a custom instance.

You can place this code in one of the following locations:

  • in the constructor of your platform-agnostic module located in the Module.cs (Module.vb) file;
  • in the Main method of the WinForms application located in the Program.cs (Program.vb) file, before the WinApplication.Start call;
  • in the Application_Start method of the ASP.NET application located in the Global.asax.cs (Global.asax.vb) file, before the WebApplication.Start call.

Expanded See Also

Is this topic helpful?​​​​​​​