Monday 16 January 2012

Change Trace Logging Directory in MS Dynamics CRM 2011


Microsoft has finally decided that we are all big boys now and that we can make some decisions, including where the trace logging files should go. The TraceDirectory key in the registry still gets summarily ignored, but it is possible to change the directory using PowerShell. It's a fairly simple process:
  1. Start PowerShell.
  2. Load the CRM PS Snap in:  Add-PSSnapin Microsoft.Crm.PowerShell
  3. Store Trace Settings into variable to allow easy editing: $trace = Get-CRMSetting TraceSettings
  4. Change Directory to your preferred value: $trace.Directory=”D:\Trace”
  5. Save Settings: Set-CRMSetting $trace
  6. You can check that the new setting has been set with: Get-CRMSetting TraceSettings
CallStack     : True
Categories    : *:Error
Directory     : D:\Trace
Enabled       : True
FileSize      : 10
ExtensionData : System.Runtime.Serialization.ExtensionDataObject
Note that the directory on step 4 needs to exist.

If you haven’t enabled trace logging, you can do it before step 4:
$trace.Enabled =”True”
Thank you Microsoft.

No comments:

Post a Comment