Fix dependency logging for hosts and services.

Fixes #6104