added trycatch for opening logfiles