Avoid unnecessary `KeyError`'s while testing.
Test for the presence of a yaml parsing log message. Fixes #6714.

Additionally, moved the yaml syntax error checking to the proper place.
If logfile cannot be opened fall back to the NULL logger

This fixes #7706

@s0undt3ch, please take a look for a more elegant solution here, but
we should be safe turning off logging for the salt command in this case
At least try to show a warning message.
Log to user home directory if user is in ACL and is unable to write to logs directory. Fixes #7706.