Being embedded in the physical world, sensor networks present a wide range of bugs and misbehavior qualitatively different than those in most distributed systems. Unfortunately, due to resource constraints, programmers must investigate these bugs with only limited visibility into application behavior. We need a new approach. This paper presents the design and evaluation of Sympathy, a tool for detecting and debugging failures in pre- and post-deployment sensor networks. Sympathy consists of mechanisms for reporting generic system and application metrics; mechanisms for identifying conditions based on these metrics; a simple debugging algorithm to detect failures based on the conditions; and a system for logging metrics and events in their spatiotemporal context. We describe Sympathy and evaluate its performance through fault injection, and by debugging an active application, ESS, in simulation, emulation, and deployment. We show that Sympathy"s analysis and choice of metrics help programmers detect failures and correlate events into the root causes of bugs.