To understand a link between the immune response and behavior, we describe a method to measure locomotor behavior in Drosophila during bacterial infection as well as the ability of flies to mount an immune response by monitoring survival, bacterial load, and real-time activity of a key regulator of innate immunity, NFκB.