.NET Core 中有哪些診斷工具可供使用?What diagnostic tools are available in .NET Core?

軟體不一定會如您預期般地運作,但是 .NET Core 具有可協助您迅速且有效地診斷這些問題的工具與 API。Software doesn't always behave as you would expect, but .NET Core has tools and APIs that will help you diagnose these issues quickly and effectively.

此文章會協助您找出所需的各種工具。This article helps you find the various tools you need.

受控偵錯工具Managed debuggers

受管理的調試程式可讓您與程式互動。Managed debuggers allow you to interact with your program. 暫停、以累加方式執行、檢查及繼續等功能,可讓您取得您程式碼行為的見解。Pausing, incrementally executing, examining, and resuming gives you insight into the behavior of your code. 偵錯工具是診斷可輕易重現之功能性問題的第一個選擇。A debugger is the first choice for diagnosing functional problems that can be easily reproduced.

記錄和追蹤Logging and tracing

記錄和追蹤是相關的技術。Logging and tracing are related techniques. 它們會參考檢測程式碼以建立記錄檔。They refer to instrumenting code to create log files. 那些檔案會記錄程式所執行之內容的詳細資料。The files record the details of what a program does. 這些詳細資料可用來診斷最為複雜的問題。These details can be used to diagnose the most complex problems. 透過與時間戳記結合,這些技術在調查效能方面的問題上也非常有用。When combined with time stamps, these techniques are also valuable in performance investigations.

單元測試Unit testing

單元測試是持續整合和部署高品質軟體的重要元件。Unit testing is a key component of continuous integration and deployment of high-quality software. 單元測試的設計是要在您中斷某個項目時提前警告您。Unit tests are designed to give you an early warning when you break something.

.NET Core dotnet 診斷通用工具.NET Core dotnet diagnostic Global Tools


dotnet-計數器是效能監視工具,可進行第一層健全狀況監視和效能調查。dotnet-counters is a performance monitoring tool for first-level health monitoring and performance investigation. 它會觀察透過 EventCounter API 發佈的效能計數器值。It observes performance counter values published via the EventCounter API. 例如,您可以快速監視 CPU 使用率,或 .NET Core 應用程式中擲回的例外狀況率等事項。For example, you can quickly monitor things like the CPU usage or the rate of exceptions being thrown in your .NET Core application.


Dotnet傾印工具是在不使用原生偵錯工具的情況下,收集和分析 Windows 和 Linux 核心傾印的方式。The dotnet-dump tool is a way to collect and analyze Windows and Linux core dumps without a native debugger.


.NET Core 包含所謂的 EventPipe,用來公開診斷資料。.NET Core includes what is called the EventPipe through which diagnostics data is exposed. Dotnet 追蹤工具可讓您從應用程式取用有趣的分析資料,以在需要執行速度緩慢的根本原因應用程式時提供協助。The dotnet-trace tool allows you to consume interesting profiling data from your app that can help in scenarios where you need to root cause apps running slow.

.NET Core 診斷教學課程.NET Core diagnostics tutorials

調試記憶體流失Debug a memory leak

教學課程:偵測記憶體流失會逐步解說找出記憶體流失的情況。Tutorial: Debug a memory leak walks through finding a memory leak. Dotnet 計數器工具是用來確認流失,而dotnet傾印工具是用來診斷遺漏的問題。The dotnet-counters tool is used to confirm the leak and the dotnet-dump tool is used to diagnose the leak.