Moved log statment so it will work when there is an exception