core: make logging of external command errors more verbose

reworked the original patches to make them fit for icinga.

fixes #4402