added sql logging for alerts