Add stack logging to writeTaskImpl