Technical Post: Using PowerShell to Address an “Invalid Trace Directory” Error in Microsoft Dynamics CRM 2011

Visit Website View Our Posts

At one of Green Beacon Solutions' clients, we kept seeing a pesky error in Microsoft Dynamics CRM 2011’s Event Log that the Trace Directory was not defined:

Invalid Trace Directory. Additional Info:[ Unable to Write file , Trace directory not defined (Reporting Process:File Name is Null. LocalTraceSettings: {Filename:  ,FileCountSuffix:1 ,TraceFileSize:10485760 ,TraceDirectory: ,TracingCallStack:Yes ,IsTracingOff:No ,LoadState:LoadSuccessfulUnreported ,RefreshTraceInt:-1 ,SiteWideRefreshTraceInt:-1 ,RegistryRefreshTraceInt:6} ] , AppDomain:CrmAsyncService)

We removed all registry keys related to Tracing, but the error kept appearing in the Event Log. With a little research, I was able to determine that the error was likely due to an invalid TraceDirectory setting of “c:\crmdrop\logs” in the DeploymentProperties table in the MSCRM_Config database. The best way to update this setting is in CRM 2011, is to use PowerShell.  Here is the specific list of commands we had to run to set the TraceDirectory to a valid value:

Add-PSSnapin Microsoft.Crm.PowerShell

Get-CrmSetting TraceSettings

$setting=Get-CrmSetting TraceSettings

$setting.Directory=”D:\Program Files\Microsoft Dynamics CRM\Trace”

Set-CrmSetting $setting

Get-CrmSetting TraceSettings

It is worth noting that we were getting the aforementioned error even when the Enabled setting was set to False.  However, once we set the TraceDirectory setting to a valid value, the errors stopped appearing in the Event Log.

If you are a Microsoft Dynamics CRM Administrator, I strong recommend reviewing the full set of PowerShell cmdlets for CRM 2011 as documented on MSDN here. While most of these settings can be controlled using Deployment Manager, others are exposed only via PowerShell.

by Green Beacon Solutions, New York Microsoft Dynamics CRM Partner

Show Buttons
Hide Buttons