Wednesday, April 18, 2012

CRM tracing

CRM tracing can be enabled via the registry. Here is the script:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM]
"TraceEnabled"=dword:00000001
"TraceRefresh"=dword:00000001

Copy the above code into a text file and rename the file to “.reg”. Run the file and tracing will be enabled.

The trace files are written to the folder: “C:\Program Files\Microsoft Dynamics CRM\Trace”.

To disable tracing use the following code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM]
"TraceEnabled"=dword:00000000
"TraceRefresh"=dword:00000000

You should be able to enable disable tracing through the use of Powershell scripts, but I could never get it working. Here is the code I wrote (that doesn’t seem to work):

Add-PSSnapin Microsoft.Crm.PowerShell

$input = Read-Host "Enable/Disable tracing (e/d)";

Write-Host "Running....";

if ($input.ToUpper() -eq "E")
{
    $setting = Get-CrmSetting TraceSettings
    $setting.Enabled="True";
    $setting.Categories="*:Verbose";
    Set-CrmSetting $setting;
    Write-Host "Trace folder: c:\Program Files\Microsoft Dynamics CRM\Trace"
}
elseif ($input.ToUpper() -eq "D")
{
    $setting = Get-CrmSetting TraceSettings
    $setting.Enabled="False";
    Set-CrmSetting $setting;
}
Write-Host "Tracesettings: ";
Get-CrmSetting TraceSettings;

Read-Host "Press any key to continue....";

No comments: