Sam June 25, 2026 0

Introduction

Debugging Dynamics 365 plugins can sometimes be challenging, especially when issues occur in production environments where attaching a debugger is not possible. A plugin may fail unexpectedly, produce incorrect results, or simply not behave as intended.

This is where Plugin Trace Logs become invaluable.

Plugin Trace Logs allow developers to capture execution details, record custom messages, and identify the root cause of plugin failures. They provide visibility into what happens during plugin execution and are one of the most effective tools for troubleshooting Dynamics 365 plugins.

📚 Related Article

Dynamics 365 Plugin Execution Pipeline

Understand how plugin stages execute before debugging plugin behavior.

What Are Plugin Trace Logs?

Plugin Trace Logs are diagnostic records generated during plugin execution.

They capture valuable information such as:

  • Custom trace messages
  • Exception details
  • Execution duration
  • Message name
  • Entity information
  • Plugin execution path

Developers can write custom messages to the trace log and review them later when troubleshooting issues.

Example:

tracingService.Trace("Plugin execution started.");

When the plugin executes, the message is stored in the corresponding Plugin Trace Log record.

Why Are Plugin Trace Logs Important?

Without trace logging, troubleshooting often looks like this:

Plugin Fails
      ↓
Generic Error Message
      ↓
Guesswork

With trace logging:

Plugin Fails
      ↓
Detailed Trace Output
      ↓
Identify Root Cause

Benefits include:

  • Faster debugging
  • Better visibility into execution flow
  • Easier production troubleshooting
  • Reduced support effort
  • Improved plugin maintainability

For most Dynamics 365 developers, Plugin Trace Logs are the first place to look when diagnosing plugin-related issues.

How to Enable Plugin Trace Logs

Plugin Trace Logs can be enabled from System Settings.

Navigate to:

Settings
↓
Administration
↓
System Settings
↓
Customization
↓
Plugin and Custom Workflow Activity Tracing

You will see the following options:

Off

No trace logs are captured.

Exceptions

Trace logs are created only when a plugin throws an exception.

All

Trace logs are created for every plugin execution.

For production environments, Microsoft generally recommends using Exceptions mode unless active troubleshooting is required.

Writing Trace Messages in a Plugin

Before writing trace messages, obtain the tracing service from the service provider.

ITracingService tracingService =
    (ITracingService)serviceProvider.GetService(
        typeof(ITracingService));

You can then write custom trace statements:

tracingService.Trace("Plugin execution started.");

tracingService.Trace(
    $"Message Name: {context.MessageName}");

tracingService.Trace(
    $"Primary Entity: {context.PrimaryEntityName}");

These messages become part of the Plugin Trace Log and can significantly simplify debugging.

Viewing Plugin Trace Logs

Once tracing is enabled, trace records can be viewed from Dynamics 365.

Navigate to:

Advanced Settings
↓
Plugin Trace Logs

Each trace log record contains information such as:

  • Plugin Name
  • Message Name
  • Primary Entity
  • Execution Duration
  • Exception Details
  • Trace Output

Reviewing these records often provides immediate insight into plugin failures and execution behavior.

Common Debugging Scenarios

Plugin Not Executing

If a plugin is not firing as expected, trace logs can help confirm whether the plugin step was triggered.

A missing trace log may indicate:

  • Incorrect step registration
  • Incorrect message configuration
  • Filtering attribute issues

Unexpected Data

Trace logs are useful for inspecting values being processed.

Example:

tracingService.Trace(
    $"Account Name: {accountName}");

This allows developers to verify whether the expected data is reaching the plugin.

Security Issues

Many plugin issues are related to security context.

Logging UserId and InitiatingUserId can help identify permission-related problems.

tracingService.Trace(
    $"UserId: {context.UserId}");

tracingService.Trace(
    $"InitiatingUserId: {context.InitiatingUserId}");

📚 Related Article

UserId vs InitiatingUserId in Dynamics 365 Plugins

Learn how user context affects plugin execution and security.

Recursive Plugin Execution

Trace logs can reveal recursion issues by displaying increasing depth values.

tracingService.Trace(
    $"Depth: {context.Depth}");

If the depth continuously increases, the plugin may be triggering itself repeatedly.

📚 Related Article

Plugin Depth Exceeded Error in Dynamics 365

Learn how recursive execution chains cause depth-related errors and how to prevent them.

Best Practices

Use Meaningful Trace Messages

Avoid generic messages such as:

tracingService.Trace("Started");

Instead use descriptive messages:

tracingService.Trace(
    $"Updating Account: {account.Id}");

Log Key Variables

When troubleshooting, logging important values can save significant time.

Examples:

  • UserId
  • MessageName
  • PrimaryEntityName
  • Record Id
  • Context Depth

Avoid Logging Sensitive Information

Never log:

  • Passwords
  • Access tokens
  • Personally identifiable information
  • Confidential business data

Trace logs may be accessible to administrators and support personnel.

Use Exception Mode in Production

The “All” option can generate a large number of records in busy environments.

For production systems, “Exceptions” mode is usually sufficient.

Remove Excessive Tracing

While trace logs are useful, excessive tracing can create noise and make troubleshooting more difficult.

Keep trace messages focused on information that provides diagnostic value.

📚 Related Article

Filtering Attributes in Dynamics 365 Plugins

Reduce unnecessary plugin executions and simplify debugging by configuring filtering attributes correctly.

Frequently Asked Questions

Do Plugin Trace Logs Impact Performance?

Minimal impact is usually observed when tracing is used appropriately. Excessive tracing should be avoided in production environments.

Should I Enable “All” Tracing in Production?

Generally no. “Exceptions” mode is recommended unless active troubleshooting is required.

Can Plugin Trace Logs Help Debug Security Issues?

Yes. Logging UserId, InitiatingUserId, and other execution context information can help identify permission-related problems.

Can Plugin Trace Logs Help Debug Plugin Depth Issues?

Yes. Logging the Context Depth property is one of the easiest ways to identify recursive plugin executions.

How Long Are Plugin Trace Logs Stored?

Plugin Trace Logs remain available until they are manually deleted or removed through maintenance processes.

Conclusion

Plugin Trace Logs are one of the most valuable debugging tools available to Dynamics 365 developers. They provide visibility into plugin execution, help identify failures, and make troubleshooting significantly easier.

Whether you’re investigating security issues, tracking execution flow, diagnosing recursion problems, or simply validating business logic, Plugin Trace Logs should be an essential part of your Dynamics 365 development toolkit.

A few well-placed trace statements can often save hours of debugging and quickly reveal the root cause of even the most complex plugin issues.

Category: