You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/msbuild/obtaining-build-logs-with-msbuild.md
+33-15Lines changed: 33 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -15,53 +15,69 @@ ms.workload:
15
15
- "multiple"
16
16
---
17
17
# Obtain build logs with MSBuild
18
+
18
19
By using switches with MSBuild, you can specify how much build data you want to review and whether you want to save build data to one or more files. You can also specify a custom logger to collect build data. For information about MSBuild command-line switches that this topic doesn't cover, see [Command-line reference](../msbuild/msbuild-command-line-reference.md).
19
20
20
21
> [!NOTE]
21
-
> If you build projects by using the Visual Studio IDE, you can troubleshoot those builds by reviewing build logs. For more information, see [How to: View, save, and configure build log files](../ide/how-to-view-save-and-configure-build-log-files.md).
22
+
> If you build projects by using the Visual Studio IDE, you can troubleshoot those builds by reviewing build logs. For more information, see [How to: View, save, and configure build log files](../ide/how-to-view-save-and-configure-build-log-files.md).
22
23
23
24
## Set the level of detail
25
+
24
26
When you build a project by using MSBuild without specifying a level of detail, the following information appears in the output log:
25
27
26
-
-Errors, warnings, and messages that are categorized as highly important.
28
+
- Errors, warnings, and messages that are categorized as highly important.
27
29
28
-
-Some status events.
30
+
- Some status events.
29
31
30
-
-A summary of the build.
32
+
- A summary of the build.
31
33
32
34
By using the **-verbosity** (**-v**) switch, you can control how much data appears in the output log. For troubleshooting, use a verbosity level of either `detailed` (`d`) or `diagnostic` (`diag`), which provides the most information.
33
35
34
36
The build process may be slower when you set the **-verbosity** to `detailed` and even slower when you set the **-verbosity** to `diagnostic`.
35
-
36
-
```cmd
37
+
38
+
```cmd
37
39
msbuild MyProject.proj -t:go -v:diag
38
40
```
39
41
42
+
### Verbosity settings
43
+
44
+
The following table shows how the log verbosity (column values) affects which types of message (row values) are logged.
You can use the **-fileLogger** (**fl**) switch to save build data to a file. The following example saves build data to a file that's named *msbuild.log*.
42
-
56
+
57
+
You can use the **-fileLogger** (**fl**) switch to save build data to a file. The following example saves build data to a file that's named *msbuild.log*.
58
+
43
59
```cmd
44
60
msbuild MyProject.proj -t:go -fileLogger
45
61
```
46
-
62
+
47
63
In the following example, the log file is named *MyProjectOutput.log*, and the verbosity of the log output is set to `diagnostic`. You specify those two settings by using the **-filelogparameters** (`flp`) switch.
For more information, see [Command-line reference](../msbuild/msbuild-command-line-reference.md).
54
70
55
71
## Save the log output to multiple files
72
+
56
73
The following example saves the entire log to *msbuild1.log*, just the errors to *JustErrors.log*, and just the warnings to *JustWarnings.log*. The example uses file numbers for each of the three files. The file numbers are specified just after the **-fl** and **-flp** switches (for example, `-fl1` and `-flp1`).
57
74
58
75
The **-filelogparameters** (`flp`) switches for files 2 and 3 specify what to name each file and what to include in each file. No name is specified for file 1, so the default name of *msbuild1.log* is used.
For more information, see [Command-line reference](../msbuild/msbuild-command-line-reference.md).
66
82
67
83
## Save a binary log
@@ -73,15 +89,17 @@ In the following example, a binary log file is created with the name *binarylogf
73
89
```cmd
74
90
/bl:binarylogfilename.binlog
75
91
```
76
-
92
+
77
93
For more information, see [Command-line reference](../msbuild/msbuild-command-line-reference.md).
78
94
79
95
## Use a custom logger
96
+
80
97
You can write your own logger by authoring a managed type that implements the <xref:Microsoft.Build.Framework.ILogger> interface. You might use a custom logger, for instance, to send build errors in email, log them to a database, or log them to an XML file. For more information, see [Build loggers](../msbuild/build-loggers.md).
81
98
82
99
In the MSBuild command line, you specify the custom logger by using the **-logger** switch. You can also use the **-noconsolelogger** switch to disable the default console logger.
83
100
84
101
## See also
102
+
85
103
<xref:Microsoft.Build.Framework.LoggerVerbosity>
86
104
[Build loggers](../msbuild/build-loggers.md)
87
105
[Logging in a multi-processor environment](../msbuild/logging-in-a-multi-processor-environment.md)
0 commit comments