In Part 1, we looked at debugging JavaScript.
In Part 2, we explored plugin debugging in DEV with the Plugin Registration Tool and plugin trace logs.
Now, let’s dive into something trickier: debugging in Sandbox and Production environments.
Why Sandbox & Production Debugging Matters
When issues arise outside DEV, attaching a debugger isn’t always an option. Instead, you rely on trace logs, custom logging, and smart error handling.
This is where real-world debugging skills shine—balancing performance, user experience, and capturing enough detail to diagnose issues effectively.
Tools in Your Toolkit
1. Plugin Trace Logs
- Enable them in Sandbox for detailed exception messages.
- Adjust the logging level (
Exception
,All
) based on the scenario.
2. Custom Logging
- Create a lightweight logging entity/table (e.g.,
new_pluginlog
). - Store details like:
- Correlation ID
- Message name
- Record ID
- Exception stack trace
- Implement cleanup/retention policies to avoid database bloat.
3. Correlation IDs
- Every error in Dynamics is tied to a correlation ID.
- Combine with Application Insights or your custom log table for cross-referencing.
4. Application Insights / Azure Monitor
- For enterprise scenarios, push plugin logs to Application Insights.
- Benefit from rich querying, dashboards, and alerting.
Key Practices
- Never debug directly in Production with a debugger attached—it’s unsupported and unsafe.
- Use Sandbox with production-like data to replicate issues before attempting fixes.
- Log enough detail to reproduce bugs without leaking sensitive information.
- Implement feature flags or environment variables for toggling verbose logging safely.
Example: Logging Exception with Correlation ID
catch (Exception ex)
{
tracingService.Trace("Plugin Error: {0}", ex.ToString());
var log = new Entity("new_pluginlog");
log["new_name"] = $"Error on {context.MessageName}";
log["new_correlationid"] = context.CorrelationId.ToString();
log["new_errordetails"] = ex.ToString();
service.Create(log);
throw;
}
Wrapping Up
Debugging in Sandbox and Production isn’t about attaching a debugger—it’s about visibility, traceability, and safe practices.
With the right mix of trace logs, custom logging, correlation IDs, and monitoring tools, you can diagnose even the trickiest issues without compromising stability.
Stay tuned for Part 4, where I’ll cover debugging Power Automate flows and integrations.
📖 If you missed them:
Top comments (0)