Enable the new TerminalLogger in .NET 8 SDK automatically

 
 
  • Gérald Barré

In .NET 8, you can use the new TerminalLogger. This terminal logger provides better output than the default console logger. It provides live progression and improves error reporting. However, it's not enabled by default. You need to use the --tl option to enable it (e.g. dotnet build --tl).

Instead of adding the flag every time you run a dotnet command, you can enable the new terminal logger by adding the MSBUILDTERMINALLOGGER environment variable. The environment variable can be set to true, false or auto:

  • true: Always use the new terminal logger
  • false: Never use the new terminal logger
  • auto: Use the new terminal logger if the console supports it

To enable the new terminal logger for the current user, run the following command in PowerShell:

PowerShell
[Environment]::SetEnvironmentVariable("MSBUILDTERMINALLOGGER", "auto", "User")

#Output comparison

The main differences between the default console logger and the terminal logger are:

  • Warnings and errors are grouped by target framework
  • The colors make it easier to read the output
  • Hyperlink for the primary output of the build, so you can click on it to open the file
  • The execution time is displayed for each target
  • The final build status is clearer

Default console logger output in .NET 8:

Terminal logger:

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub