Skip to content

Plugin Diagnostic Logging

Damon Tivel edited this page Apr 30, 2019 · 3 revisions

Plugin Diagnostic Logging

NuGet 5.1.0 includes opt-in diagnostic plugin logging. This logging can help diagnose issues involving NuGet plugins.

This logging only pertains to the new plugin model that enabled package download and cross-platform authentication plugins. It does not pertain to older, Windows-only credential plugins.

Enabling Logging

To enable diagnostic plugin logging set the environment variable NUGET_PLUGIN_ENABLE_LOG to true.

By default log files are created in the current working directory. To override this default set the environment variable NUGET_PLUGIN_LOG_DIRECTORY_PATH to a fully qualified directory path.

Here is an example using both environment variables in PowerShell:

$Env:NUGET_PLUGIN_ENABLE_LOG='true'
$Env:NUGET_PLUGIN_LOG_DIRECTORY_PATH='C:\logs'

.\NuGet.exe restore .\MySolution.sln

Inspecting Log Files

When logging is enabled, each NuGet client and plugin process using NuGet.Protocol 5.1.0 or later will generate its own log file, and each log file will provide a one-sided history of a NuGet-plugin session.

For instance, a NuGet client process --- whether running in NuGet.exe, dotnet.exe, or Visual Studio --- will generate one log file. This file will contain the NuGet client's history of all interactions with every plugin throughout the NuGet client process's lifetime. Also, each plugin process will generate its own log file, which will contain the plugin process's history of all interactions with that NuGet client process.

As diagnostic plugin logging was added in NuGet 5.1.0, versions of the NuGet.Protocol package, which both NuGet clients and plugins use, older than 5.1.0 cannot participate in diagnostic plugin logging. That means if the NuGet client (e.g.: NuGet.exe) is 5.1.0 or later, but a plugin is using a version of NuGet.Protocol older than 5.1.0, the NuGet client will generate a log file but the plugin will not. While having only one and not both log files for a single NuGet-plugin session is suboptimal, that one log file may still be useful.

The NuGet plugin log viewer can combine all log files for a single NuGet-plugin session and provide a coherent view for that session.

Contributing

What's Being Worked On?

Check out the proposals in the accepted & proposed folders on the repository, and active PRs for proposals being discussed today.

Common Problems

Clone this wiki locally