Have you looked at: http://docs.python.org/2/howto/logging-cookbook#adding-contextual-information-to-your-logging-output ?