Error logging and event managment