TFS Activity Logging in TFS 2005/2008

There is a feature of TFS that allows all commands run through it logged to an internal database.  This is the TfsActivityLogging database and one of its key features is that it can never grow to large.  If enabled, activity logging will log all commands with a minimal overhead and will only log the last seven days.  Here is how you enable it and a brief tutorial on how to use it.

Enabling TFS Activity Logging

WARNING:  Changing the web.config file for a web application in IIS will force an application pool reset!  Consider yourself warned!

  1. open the <TFS Instal Path>\Webservices\web.config file
  2. locate the following element <add key="commandLogging" value="None"/> and change "None" to "All"
  3. The application pool will restart and logging will be enabled until the above value is changed back to "None"

Logging is now enabled, how do you use it I hear you cry?

Viewing the TfsActivityLoggging Data

WARNING:  Do not touch ANY other databases that TfsActivityLogging, to do so may severly damage your instance of TFS and put your data at risk!  Seriously, just don't do it.  Even if you have backups. Ever.

Connect to the Data tier using SQL Server Management Studio, right click on "TfsActivityLogging" and run the following SQL query:

Select

* from tbl_command c left join tbl_parameter p on c.commandid = p.commandid

This will return all commands. For a Version Control commands append the following to the above;
where c.Application = 'Version Control'

other applications are: Data Warehouse, Integration, WorkItemTracking, Proxy

Have fun,
Jason

PS.  Seriously, don't play with your databases, it ends badly!