Okay, so if you are a TFS Build user, you probably are familiar with this scenario… You setup a new build definition and get it working. It works for days maybe weeks, then suddenly builds start failing sporadically for no apparent reason. You have several failed builds and none of them have any useful information. So, you turn the verbosity up on your build to diagnostic so you can repeat the build and get some additional information. The build is running a little slower now and instead of failing, it succeeds. Eventually, you’ll get a failed build that you have enough logging on to fix, but getting there can be a real pain.
Well, in TFS11 we decided to create diagnostic logs all the time. However, we don’t want to slow down the build. So, we write the diagnostic logs to files and copy them to the drop location. These logs are written in an xml format, and we provide a transform to display it nicely in a browser.
From the Build Details View you can click on the new Diagnostics sub menu to View the logs for a completed build. (Note this only works for builds that have a drop location – gated and private builds don’t necessarily have them.)
This menu item will open the drop folder location that contains the logs for this build. From there you can choose which file to open. We generate one file for the controller and one for each agent that was used during the build. So, if you know the error was on the agent you can jump straight there. If you aren’t sure, start in the controller log and you can click on links there that will open the agent logs.
But what about hung builds…
Unfortunately, a build can get stuck in many different ways even in TFS 11. Sometimes the only way to see where the build is stuck is to view the diagnostic logs. Especially since the build may just be going really slow for some reason. You don’t want to have to stop the build to see what’s wrong.
While a build is in progress, the Diagnostics menu contains another option to request that the logs be put on the drop location (it’s called Request Logs).
If you request logs during the build, they will be copied out to the drop location as they are. Once that finishes, the Diagnostics menu will contain a menu item to view the logs produced at that time. Those logs will still exist even once the build is finished. They are placed under a directory that has the date time they were requested as the name.
We hope this will make diagnosing strange build failures a little easier for everyone. It also allows all the paranoid build admins to speed up their builds by reducing the verbosity to Minimal (that’s our new default in TFS11).