113

I am using Visual Studio Express 2012. Where is the location of the log file? I have searched in the folder where my solution and projects are stored, but cannot find any .log file.

This is the configuration for logging:

enter image description here

Hanxue
  • 12,243
  • 18
  • 88
  • 130

4 Answers4

113

Log file from Visual Studio is only supported for C++ projects. You just have to work with the output window for others.

See this similar thread: VS2010: minimal build log in output and detailed log in log file

And in case you happen to do this for a C++ project, the file is at:

... build log in the intermediate files directory ... The path and name of the build log is represented by the MSBuild macro expression, $(IntDir)\$(MSBuildProjectName).log.

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
Dmitry Pavlov
  • 30,789
  • 8
  • 97
  • 121
  • 18
    I think that's just silly of Visual Studio not to have detailed logging in a file. Oh well, a reality I have to accept. Thanks for your answer, @Dmitry – Hanxue Jul 18 '12 at 22:48
  • 8
    @hanxue - It does have a log. That log is just not sent to a file. If you want a log file, run msbuild from the command line. – Ritch Melton Jul 19 '12 at 01:16
  • 54
    THEN WHY DOESN'T IT SAY SO :-( – Simon_Weaver Jun 30 '16 at 20:33
  • 2
    God. Damnit. Why isnt this just a property on the solution? Why is the output window so terrible performance anyway so you are forced to keep it on minimal output all the time, and why is it like 8 steps to change from one output level to the other? Fix any of these please. – James Jul 11 '16 at 01:54
  • @James I guess you could be able to write a macro and assign it to the toolbar button. These links could be a starting point http://stackoverflow.com/questions/12062515/can-i-record-play-macros-in-visual-studio-2012-2013-2015 and https://vlasovstudio.com/visual-commander/ – Dmitry Pavlov Jul 16 '16 at 19:44
  • @Okonomiyaki3000 `IntDir` means intermediate directory https://learn.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=vs-2019 – Dmitry Pavlov Jun 19 '19 at 17:18
  • not the answer I'm looking for. but yeah. that's how MS works – aj go Jun 13 '21 at 12:51
32

Use build output instead of logging to file. Instead of copy/paste, simply click somewhere in the output and press CTRL + S to save. Visual Studio will prompt you for a location (tested with Visual Studio 2017, but I'm assuming this works in earlier versions too).

enter image description here

Dan Gøran Lunde
  • 5,148
  • 3
  • 26
  • 24
  • This is good. They should put this in the context menu as well. – Sheen Nov 12 '18 at 23:41
  • 3
    not useful for me because the logs in output doesn't have the complete log output – aj go Jun 13 '21 at 12:57
  • @ajgo build output level of details is configurable in MSBuild build project output verbosity as show in the screenshot in the original question – Andrey Feb 12 '22 at 21:21
  • 1
    I tried that to set it to verbose and the full detail was just truncated which I have said before. it doesn't have the complete log output – aj go Feb 22 '22 at 00:56
24

The msdn documentation is pretty clear about this (And you ain't gonna like it!):

https://msdn.microsoft.com/en-us/library/jj651643.aspx

Where it says:

To create a build log file for a managed-code project On the menu bar, choose Build, Build Solution.

In the Output window, highlight the information from the build, and then copy it to the Clipboard.

Open a text editor, such as Notepad, paste the information into the file, and then save it.

C.J.
  • 15,637
  • 9
  • 61
  • 77
  • 22
    Which is all well and good until you're using diagnostic output and VS decides to throw an 'out of memory' exception when you try to copy to the clipboard. Really is a fundamentally stupid decision not to support sending the build log to a file in the IDE. But hey ho, such is life. – Steve Pettifer Nov 01 '16 at 11:12
  • 1
    Pipe the build into a text file? msbuild mysln.sln >output.txt (will probably need to add parameters to that to get your sln to compile, but you should be able to snag that from vs output window iirc at the correct verbosity level) – Daniel M Jan 19 '17 at 16:58
  • Usually when I build on the command line, I make my build systems output minimal information to the terminal window, but a detailed log to a file. MSBuild can do that. – C.J. May 24 '18 at 17:31
  • "And you ain't gonna like it!" That tells everything in 6 words, thanks – F.I.V Aug 25 '19 at 05:35
2

While it's true that VS doesn't allow this directly, it is still possible to build with MSBuild "inside" VS2015 and get both the build window output and the log file, as follows: (Arguably this is a bit of a hack.)

  1. In your VS Managed solution, add a new project (Let's call it 'Make'). a. The project type you want is Visual C++/NMake project.
  2. Define the MSBuild commands you need on the command line (see below).
  3. Change the solution configuration to build the NMake project instead of the normal managed projects.

This will create a project that has Build, Rebuild, and Clean command lines where you can execute MSBuild directly. For example:

Rebuild: MSBuild.exe /ds /v:diag /property:Configuration=Debug ..\BuildTest\BuildTest.csproj /t:Clean,Build

Build: MSBuild.exe /ds /v:diag /property:Configuration=Debug ..\BuildTest\BuildTest.csproj /t:Build

Clean: MSBuild.exe /ds /v:diag /property:Configuration=Debug ..\BuildTest\BuildTest.csproj /t:Clean

You can also specify multiple MSBuild.EXE command lines in order to build multiple projects. For the usual build-the-entire-solution outcome you can target only the final end assemblies and let the dependency graph generate the individual targets.

This will produce a .log file, where NAME is the name of the NMake project you used. In the example above, the log would be make.log.

A working example is available on GitHub: https://github.com/bitblitz/VS_MsbuildExample (Tested with VS2015)

Note that building individual projects directly will still build with the normal VS behavior, but you can build the full solution inside VS and get the build logs.

Brad
  • 3,190
  • 1
  • 22
  • 36