|
1 | 1 | ---
|
2 |
| -title: 'View, save, and configure build log files' |
3 |
| -description: View, save, and configure build log files that contain information such as the command lines used for the compiler and other tools, and troubleshoot build failures. |
4 |
| -ms.date: 11/11/2022 |
| 2 | +title: View, save, and configure build log files |
| 3 | +description: Explore how to configure build log files with information about the compiler and other tools for troubleshooting build failures. |
| 4 | +ms.date: 08/21/2024 |
5 | 5 | ms.subservice: compile-build
|
6 | 6 | ms.topic: how-to
|
7 | 7 | author: ghogen
|
8 | 8 | ms.author: ghogen
|
9 | 9 | manager: mijacobs
|
| 10 | + |
| 11 | +#customer intent: As a developer, I want to work with build log files in Visual Studio so I can troubleshoot build failures. |
10 | 12 | ---
|
| 13 | + |
11 | 14 | # View, save, and configure build log files
|
12 | 15 |
|
13 |
| -After you build a project in the Visual Studio IDE, you can view information about that build in the **Output** window. By using this information, you can troubleshoot a build failure, view the exact command lines used for all the build tools, or get full diagnostic information about the entire build process. |
| 16 | +After you build a project in the Visual Studio Interactive Development Environment (IDE), you can view logged information about the build in the Visual Studio **Output** window. The output data can be saved to log files that you can view in Visual Studio and other editors. |
| 17 | + |
| 18 | +The logs can help you troubleshoot issues in the build. You can locate the exact command lines used for all build tools, and get full diagnostic data about the entire build process. Visual Studio provides options to specify the kinds of information you want to see in the build output and build log files. |
| 19 | + |
| 20 | +This article describes how to generate, configure, and view build log files in Visual Studio. |
| 21 | + |
| 22 | +## Generate and view build log files |
| 23 | + |
| 24 | +Use the following procedures to generate and view build log files for your scenario. |
14 | 25 |
|
15 |
| -- For C++ projects, you can also view the same information in a log file that's created and saved when you build a project. |
| 26 | +- **C++ project**: |
16 | 27 |
|
17 |
| -- For .NET projects, you can click in the build output window and press **Ctrl**+**S**. Visual Studio prompts you for a location to save the information from the **Output** window into a log file. |
| 28 | + Visual Studio saves the log files for you when you build your project. Common locations for the log files include *Release\\\<ProjectName>.log*, *Debug\\\<ProjectName>.log*, and *\<ProjectName>.txt*. All file locations are relative to your project root folder and based on your specific configuration. |
18 | 29 |
|
19 |
| -You can also use the IDE to specify what kinds of information you want to view about each build. |
| 30 | + 1. Use **Windows Explorer** or **File Explorer** to browse to the log file. |
| 31 | + |
| 32 | + 1. Open the log file in your preferred editor. |
20 | 33 |
|
21 |
| -If you build any kind of project by using MSBuild, you can create a log file to save information about the build. For more information, see [Obtain build logs](../msbuild/obtaining-build-logs-with-msbuild.md). |
| 34 | +- **.NET project**: |
22 | 35 |
|
23 |
| -## To view the build log file for a C++ project |
| 36 | + For .NET projects, you instruct Visual Studio to save the log files: |
24 | 37 |
|
25 |
| -1. In **Windows Explorer** or **File Explorer**, open the following file (relative to the project root folder): *Release\\{ProjectName}.Log* or *Debug\\{ProjectName}.log* |
| 38 | + 1. In Visual Studio, select **Build** > **Build Solution**. |
26 | 39 |
|
27 |
| -## To create a build log file for a managed-code project |
| 40 | + 1. In the **Output** window, select in the text and use the **Ctrl**+**S** keyboard shortcut. |
| 41 | + |
| 42 | + Visual Studio prompts you for a location to save the build output. You can then open the log files from that location in Visual Studio or another editor. |
28 | 43 |
|
29 |
| -1. On the menu bar, choose **Build** > **Build Solution**. |
| 44 | +- **MSBuild**: |
30 | 45 |
|
31 |
| -2. In the **Output** window, click somewhere in the text. |
| 46 | + You can generate build logs by running MSBuild directly from the command line by using the `-fileLogger` (`-fl`) command-line option. For more information, see [Obtain build logs with MSBuild](../msbuild/obtaining-build-logs-with-msbuild.md). |
32 | 47 |
|
33 |
| -3. Press **Ctrl**+**S**. |
| 48 | +## Specify data verbosity for build logs |
34 | 49 |
|
35 |
| - Visual Studio prompts you for a location to save the build output. |
| 50 | +You can specify how much information to include in the build log files. The amount of data in the log file columns is measured as *logger verbosity*. The number of log file rows represent *messages collected*. The log verbosity (column values) affects the types of logged messages (row values). **Quiet** verbosity produces minimal logging in the build output. **Diagnostic** is the most verbose setting and generates log files with all possible data. |
36 | 51 |
|
37 |
| -You can also generate logs by running MSBuild directly from the command line, using the `-fileLogger` (`-fl`) command-line option. See [Obtain build logs with MSBuild](../msbuild/obtaining-build-logs-with-msbuild.md). |
| 52 | +The following table shows what types of messages are collected based on the logger verbosity: |
38 | 53 |
|
39 |
| -## To change the amount of information included in the build log |
| 54 | +| Message type / Verbosity | Quiet | Minimal | Normal | Detailed | Diagnostic | |
| 55 | +|------------------------------------|:-----:|:-------:|:------:|:--------:|:----------:| |
| 56 | +| Errors | ✅ | ✅ | ✅ | ✅ | ✅ | |
| 57 | +| Warnings | ✅ | ✅ | ✅ | ✅ | ✅ | |
| 58 | +| High-importance messages | | ✅ | ✅ | ✅ | ✅ | |
| 59 | +| Normal-importance messages | | | ✅ | ✅ | ✅ | |
| 60 | +| Low-importance messages | | | | ✅ | ✅ | |
| 61 | +| Other MSBuild-engine information | | | | | ✅ | |
40 | 62 |
|
41 |
| -1. On the menu bar, choose **Tools** > **Options**. |
| 63 | +You can configure the logger verbosity with the following steps: |
42 | 64 |
|
43 |
| -2. On the **Projects and Solutions** page, choose the **Build and Run** page. |
| 65 | +1. In Visual Studio, select **Tools** > **Options** to open the **Options** dialog. |
44 | 66 |
|
45 |
| -3. In the **MSBuild project build output verbosity** list, choose one of the values, and then choose the **OK** button. |
| 67 | +1. On the dialog, expand the **Projects and Solutions** section and select the **Build and Run** tab. |
46 | 68 |
|
47 |
| -The following table shows how the log verbosity (column values) affects which types of message (row values) are logged. |
| 69 | +1. Use the **MSBuild project build output verbosity** dropdown list and select your build output preference. |
48 | 70 |
|
49 |
| -| Message type / Verbosity | Quiet | Minimal | Normal | Detailed | Diagnostic | |
50 |
| -|---------------------------------------|:-----:|:-------:|:------:|:--------:|:----------:| |
51 |
| -| Errors | ✅ | ✅ | ✅ | ✅ | ✅ | |
52 |
| -| Warnings | ✅ | ✅ | ✅ | ✅ | ✅ | |
53 |
| -| High-importance Messages | | ✅ | ✅ | ✅ | ✅ | |
54 |
| -| Normal-importance Messages | | | ✅ | ✅ | ✅ | |
55 |
| -| Low-importance Messages | | | | ✅ | ✅ | |
56 |
| -| Additional MSBuild-engine information | | | | | ✅ | |
| 71 | +1. Use the **MSBuild project build log file verbosity** dropdown list and select your logger verbosity preference. |
57 | 72 |
|
58 |
| -If you want to see the command lines used for the compiler and other tools, choose at least the **Detailed** verbosity level. |
| 73 | + > [!TIP] |
| 74 | + > If you want to see the command lines used for the compiler and other tools, choose at least the **Detailed** verbosity level. |
59 | 75 |
|
60 |
| -For more information, see [Options dialog box, Projects and Solutions, Build and Run](../ide/reference/options-dialog-box-projects-and-solutions-build-and-run.md) and <xref:Microsoft.Build.Framework.LoggerVerbosity>. |
| 76 | +1. To apply your changes, select **OK**. |
61 | 77 |
|
62 | 78 | > [!IMPORTANT]
|
63 |
| -> You must rebuild the project for your changes to take effect in the **Output** window (all projects) and the *\<ProjectName>.txt* file (C++ projects only). |
| 79 | +> You must rebuild the project for your changes to take effect in the **Output** window. For C++ projects, the project rebuild also ensures the changes are reflected in the *\<ProjectName>.txt* file. |
64 | 80 |
|
65 |
| -## Use binary logs to make it easier to browse large log files |
| 81 | +For more information, see [Options dialog box, Projects and Solutions, Build and Run](./reference/options-dialog-box-projects-and-solutions-build-and-run.md) and <xref:Microsoft.Build.Framework.LoggerVerbosity>. |
| 82 | + |
| 83 | +## Use binary logs for large log files |
66 | 84 |
|
67 | 85 | :::moniker range="<=vs-2019"
|
| 86 | + |
68 | 87 | Binary logs are an optional feature for .NET projects that lets you have a richer log browsing experience that might make it easier to find information in large logs. To use binary logs, install the [Project System Tools](https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools). For more information, see [`https://msbuildlog.com`](https://msbuildlog.com) and [Binary Log](https://github.com/microsoft/msbuild/blob/master/documentation/wiki/Binary-Log.md).
|
| 88 | + |
69 | 89 | :::moniker-end
|
70 | 90 | :::moniker range=">=vs-2022"
|
| 91 | + |
71 | 92 | Binary logs are an optional feature for .NET projects that lets you have a richer log browsing experience that might make it easier to find information in large logs. To use binary logs, install the [Project System Tools 2022](https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022). For more information, see [`https://msbuildlog.com`](https://msbuildlog.com) and [Binary Log](https://github.com/microsoft/msbuild/blob/master/documentation/wiki/Binary-Log.md).
|
| 93 | + |
72 | 94 | :::moniker-end
|
73 | 95 |
|
74 | 96 | ## Related content
|
75 | 97 |
|
76 |
| -- [Build and clean projects and solutions in Visual Studio](../ide/building-and-cleaning-projects-and-solutions-in-visual-studio.md) |
77 |
| -- [Compile and build](../ide/compiling-and-building-in-visual-studio.md) |
78 |
| -- [Obtaining build logs with MSBuild](../msbuild/obtaining-build-logs-with-msbuild.md) |
| 98 | +- [Build and clean projects and solutions in Visual Studio](building-and-cleaning-projects-and-solutions-in-visual-studio.md) |
| 99 | +- [Compile and build](compiling-and-building-in-visual-studio.md) |
| 100 | +- [Obtain build logs with MSBuild](../msbuild/obtaining-build-logs-with-msbuild.md) |
0 commit comments