Improve log messages for failed commands

fixes #6970