Save logs in the database