Log errors when logging to db