fixing the creation of the logs folder. Now also created when exiting on error.