Updated to account for situation where logname command fails.