How to collect .NET Core dump on Linux Web App

Published Apr 08 2021 04:12 AM 3,554 Views
Microsoft

While many blogs talk about capturing memory dump for .NET application on Windows platform, this blog introduces one way of collecting .NET Core dump on Linux Web App with dotnet-dump tool.

 

1. SSH to web app.

 

YangYu_5-1617879132510.png

 

2. Check dotnet process id. In example below, process id of the web app is 29.

 

ps aux | grep dotnet

 

YangYu_4-1617879037505.png

 

3. Change directory to persistent storage.

 

cd /home/LogFiles

 

4. Capture dotnet core dump.

 

dotnet-dump collect  -p [process-id]  --type Full  --diag

 

-p|--process-id <PID>

Specifies the process ID number to collect a dump from.

 

--type <Full|Heap|Mini>

Specifies the dump type, which determines the kinds of information that are collected from the process. There are three types:

Full - The largest dump containing all memory including the module images.

Heap - A large and relatively comprehensive dump containing module lists, thread lists, all stacks, exception information, handle information, and all memory except for mapped images.

Mini - A small dump containing module lists, thread lists, exception information, and all stacks.

 

--diag

Enables dump collection diagnostic logging.

 

5. Once capture completed, we should be able to see dump file in the "/home/LogFiles" directory.

 

YangYu_3-1617878880289.png

 

Limitations:

Unlike capturing memory dump on Windows Web App with procdump, dotnet-dump tool offers manual dump capture only by the time of writing. In other words, we cannot configure conditional capture to automatically collect memory dump based on cpu threshold, memory threshold or occurrence of exceptions, like we usually do on Windows Web App. Manual capture is needed in those scenarios.

 

References:

https://docs.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-dump

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2260713%22%20slang%3D%22en-US%22%3EHow%20to%20collect%20.NET%20Core%20dump%20on%20Linux%20Web%20App%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2260713%22%20slang%3D%22en-US%22%3E%3CDIV%20style%3D%22direction%3A%20ltr%3B%20border-width%3A%20100%25%3B%22%3E%0A%3CDIV%20style%3D%22direction%3A%20ltr%3B%20margin-top%3A%200in%3B%20margin-left%3A%200in%3B%20width%3A%207.6041in%3B%22%3E%0A%3CDIV%20style%3D%22direction%3A%20ltr%3B%20margin-top%3A%200in%3B%20margin-left%3A%200in%3B%20width%3A%207.6041in%3B%22%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3EWhile%20many%20blogs%20talk%20about%20capturing%20memory%20dump%20for%20%3CSTRONG%3E.NET%3C%2FSTRONG%3E%20application%20on%20%3CSTRONG%3EWindows%3C%2FSTRONG%3E%20platform%2C%20this%20blog%20introduces%20one%20way%20of%20collecting%26nbsp%3B%3CSTRONG%3E.NET%20Core%3C%2FSTRONG%3E%20dump%20on%20%3CSTRONG%3ELinux%20Web%20App%3C%2FSTRONG%3E%20with%20%3CSTRONG%3Edotnet-dump%3C%2FSTRONG%3E%20tool.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E1.%20SSH%20to%20web%20app.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22YangYu_5-1617879132510.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271052i66EECB33DCBC95AE%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22YangYu_5-1617879132510.png%22%20alt%3D%22YangYu_5-1617879132510.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E2.%20Check%20dotnet%20process%20id.%20In%20example%20below%2C%20process%20id%20of%20the%20web%20app%20is%2029.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3Eps%20aux%20%7C%20grep%20dotnet%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22YangYu_4-1617879037505.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271051i706F6B3D636AF8E4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22YangYu_4-1617879037505.png%22%20alt%3D%22YangYu_4-1617879037505.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E3.%20Change%20directory%20to%20persistent%20storage.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3Ecd%26nbsp%3B%2Fhome%2FLogFiles%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E4.%20Capture%20dotnet%20core%20dump.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3Edotnet-dump%20collect%26nbsp%3B%20-p%20%5Bprocess-id%5D%26nbsp%3B%20--type%20Full%26nbsp%3B%20--diag%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E-p%7C--process-id%20%3CPID%3E%3C%2FPID%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3ESpecifies%20the%20process%20ID%20number%20to%20collect%20a%20dump%20from.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E--type%20%3CFULL%3E%3C%2FFULL%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3ESpecifies%20the%20dump%20type%2C%20which%20determines%20the%20kinds%20of%20information%20that%20are%20collected%20from%20the%20process.%20There%20are%20three%20types%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3EFull%20-%20The%20largest%20dump%20containing%20all%20memory%20including%20the%20module%20images.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3EHeap%20-%20A%20large%20and%20relatively%20comprehensive%20dump%20containing%20module%20lists%2C%20thread%20lists%2C%20all%20stacks%2C%20exception%20information%2C%20handle%20information%2C%20and%20all%20memory%20except%20for%20mapped%20images.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3EMini%20-%20A%20small%20dump%20containing%20module%20lists%2C%20thread%20lists%2C%20exception%20information%2C%20and%20all%20stacks.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3E--diag%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%3CFONT%20size%3D%223%22%3EEnables%20dump%20collection%20diagnostic%20logging.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%20lang%3D%22zh-CN%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E5.%20Once%20capture%20completed%2C%20we%20should%20be%20able%20to%20see%20dump%20file%20in%20the%20%22%2Fhome%2FLogFiles%22%20directory.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22YangYu_3-1617878880289.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271050i41A1790E57CCDB94%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22YangYu_3-1617878880289.png%22%20alt%3D%22YangYu_3-1617878880289.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CSTRONG%3ELimitations%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3EUnlike%20capturing%20memory%20dump%20on%20%3CSTRONG%3EWindows%20Web%20App%3C%2FSTRONG%3E%20with%20%3CSTRONG%3Eprocdump%2C%3C%2FSTRONG%3E%20%3CSTRONG%3Edotnet-dump%3C%2FSTRONG%3E%20tool%20offers%20manual%20dump%20capture%20only%20by%20the%20time%20of%20writing.%20In%20other%20words%2C%20we%20cannot%20configure%20conditional%20capture%20to%20automatically%20collect%20memory%20dump%20based%20on%20cpu%20threshold%2C%20memory%20threshold%20or%20occurrence%20of%20exceptions%2C%20like%20we%20usually%20do%20on%20%3CSTRONG%3EWindows%20Web%20App%3C%2FSTRONG%3E.%20Manual%20capture%20is%20needed%20in%20those%20scenarios.%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3EReferences%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fcore%2Fdiagnostics%2Fdotnet-dump%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fcore%2Fdiagnostics%2Fdotnet-dump%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20font-family%3A%20Calibri%3B%20font-size%3A%2011.0pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2260713%22%20slang%3D%22en-US%22%3E%3CP%3EInstructions%20on%20capturing%20.NET%20Core%20dump%20on%20Linux%20Web%20App%20with%20dotnet-dump%20tool.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2260713%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E.%20NET%20Core%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20App%20Service%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Jul 20 2021 08:31 AM
Updated by: