Displaying error message if log file cannot be written

Fixes #1529