I've been searching for a way to add the SqlTrackingService to the WorkflowApplication in WF4 similar to the way it can be done in WF3 as follows:
WorkflowRuntime wr = new WorkflowRuntime();
SqlTrackingService ts = new SqlTrackingService("Initial Catalog=Tracking;Data
Source=localhost;Integrated Security=SSPI;");
ts.UseDefaultProfile = true;
wr.AddService(ts);
wr.StartRuntime();
Thanks in advance!
WF4 has the concept of TrackingParticipant. You can attach tracking participants to your workflow execution and it will receive its events.
You can implement a SQLTrackingParticipant. Check these WF examples where you've available an example of an custom SQLTrackingParticipant on \WF\Basic\Tracking\SqlTracking folder.