How to enable build agent or build controller’s logs?

Here are the steps which I typically perform to enable build agent/controller logs.

1. Go to the build agent/controller installation directory (typically it is something like C:\Program Files\Microsoft Team Foundation Server 2010\Tools).

2. Create a new configuration file named TFSBuildServiceHost.exe.config with the following content:

            <add name="BuildServiceTraceLevel" value="4"/>
        <trace autoflush="true" indentsize="4">
                <add name="myListener" type="Microsoft.TeamFoundation.TeamFoundationTextWriterTraceListener,Microsoft.TeamFoundation.Common, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" initializeData="c:\logs\TFSBuildServiceHost.exe.log" />
         <remove name="Default" />

3. Create a new directory named c:\logs and ensure that the account under which the service Visual Studio Team Foundation Build Service Host has write permission on c:\logs.

4. Restart the build controller/agent service (net stop tfsbuildservicehost & net start tfsbuildservicehost).

After this a log file named TFSBuildServiceHost.exe.log should get generated in c:\logs directory.