log events to db