added logging and email notification for app errors