This article is contributed. See the original author and article here.

The following two procedures guide on how to collect traces of exceptions when the application is not using a logging or telemetry solution – such as Application Insights – to record those exceptions. This post complements my article about how exceptions are handled and how to collect memory dumps to study them.


 


Both tools below – ProcDump and DebugDiag – work similarly: they can attach themselves as debuggers to a process, then monitor and log exceptions for that process. Optionally, these tools can collect a memory dump for the monitored process under certain conditions – such as when specific exceptions occur.


Both tools need administrative rights to be run.


DebugDiag is the preferred tool, since it automates some steps, adds more explicit context, and includes automated memory dump analysis capabilities too. While ProcDump will report exceptions occurring, DebugDiag will also collect thread call stack information.


 


Using the command-line ProcDump


 


ProcDump does not require installation. But one needs to be specific about the PID to which it is attaching. That PID needs to be determined prior to starting ProcDump. This may be tricky when the respective process is crashing and restarting frequently, with a different PID; such as when Asp.Net apps are causing their w3wp.exe to crash and restart.


 



  1. Download the tool and copy it on a disk folder, for example D:Temp-Dumps
    https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
     

  2. Open an administrative console from where to run commands.
    Navigate to the disk folder above (D:Temp-Dumps).
     

  3. Find the process ID, the PID, of the IIS w3wp.exe worker process executing your application.
    Use the AppCmd IIS tool to list processes for application pools:
    C:WindowsSystem32InetSrvappcmd.exe list wp

     

  4. Execute the following command to collect the traces:
    D:Temp-Dumps> procdump.exe -accepteula -e 1 -f “” [PID]

    You may want to redirect the console output of ProcDump to a file, to persist the recording of the encountered exceptions:

    D:Temp-Dumps> procdump.exe -accepteula -e 1 -f “” [PID] > Monitoring-log.txt

    Replace [PID] with the actual Process ID integer number identified at the step 2.
     

  5. Start reproducing: issue requests from the client (browser?) that you know it would trigger exception(s); usually, HTTP response “500, Server-side processing error“.
    Or simply wait or make requests to the IIS/Asp.Net app until the exception(s) occur(s).
    You should end up with a console output revealing the exceptions, or
    a .TXT log with them in the location where ProcDump.exe was saved (example: D:Temp-Dumps).


 


 


 


Using the UI tool DebugDiag, Debug Diagnostics Collection


 


DebugDiag requires installation, but it is able to determine itself the whatever process instance – PID – happens to execute for an application pool at some point in time; even when that process may occasionally crash, hence restart with different PID.


 


 


 


1.


Download Debug Diagnostic and install it on IIS machine:


https://www.microsoft.com/en-us/download/details.aspx?id=49924 v2.2


https://www.microsoft.com/en-us/download/details.aspx?id=58210 v2.3


https://www.microsoft.com/en-us/download/details.aspx?id=102635 v2.3.1 


 


 


 


2.


Open Debug Diagnostic Collection.
If a wizard does not show up, click Add Rule.
 


Viorel-Alexandru_0-1616691775841.png


 


 


 


3.


Choose Crash and click Next.


 


Viorel-Alexandru_1-1616691775856.png


 


 


 


4.


Choose “A specific IIS web application pool” and Next.


 


Viorel-Alexandru_2-1616691775866.png


 


 


 


5.


Select the application pool which runs the problematic application and then click Next.


 


Viorel-Alexandru_3-1616691775872.png


 


 


 


6.


The Unconfigured First-Chance Exceptions are the unknown ones that we want to determine…
Let’s Log Stack Trace for these; say the first 100 occurrences.
Lower the Maximum number of userdumps created by the rule to 1 (would only get a dump if we have a crash; but at this stage we’re not after dumps).
Then click Next


 


Viorel-Alexandru_4-1616691775881.png


 


 


 


7.


Configure the file location where the (potential) dump file(s) will be generated/written.
A dump would only be collected on crash, if it happens; otherwise, we should only have a text file as output: a monitoring log, where occurred first-chance exceptions are recorded.
Please note that a dump file is a snapshot of the process memory, written in disk; size will be similar to process memory as seen in the Task Manager.
For example, if you see that w3wp.exe uses around 5 GB of memory in Task Manager, then the dump of that process will be around 5 GB on the disk.
Please do not choose a disk in network/UNC; choose a local disk.


 


Viorel-Alexandru_5-1616691775894.png


 


 


 


8.


Click Next and Finish by selecting to Activate the rule now.


 


Viorel-Alexandru_6-1616691775898.png


 


 


 


9.


Unknown/Unconfigured first-chance exceptions will be recorded; therefore, revealed.


If the application pool’s w3wp.exe process would crash with an unhandled exception, we would also get a memory dump.


If dump is generated, archive in a ZIP and hand over to the support engineer or to the development team that should be aware of these exceptions.


 


Remember my article about how exceptions are handled and how to collect memory dumps to study them. We can double check if a crash occurred or not: read about w3wp.exe crashes.


 


 

Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.