Thursday 28 February 2013

Removing stack trace from Microsoft Dynamics CRM 2011 log files.

If you've ever had to do any serious troubleshooting with MS Dynamics CRM, you know how annoying the log files can get with all the stack trace information that 99% of the times tells you nothing of use.

You can use the following PowerShell commands to remove them. Note that Exception Stack traces will still be there, use \s instead of \t if your really want to get rid of them.
Get-Content CrmTraceFile.log | Select-String "^[\t]" -NotMatch  | Out-File -Width 256 newlogfile.log
You could do it for all files in the trace directory like this, which should be used as a script:
$files = ls
foreach ($file in $files){  
$name = [string]::Format("p_{0}",$file.Name)
 $filepath = [string]::Format("{0}\{1}", $file.DirectoryName,$file.Name)
 get-content -Path $filepath | select-string "^[\t]" -notmatch | out-file $name -width 256 

No comments:

Post a Comment