Log to the database asynchronously