Moved logging logic in rewrite task so it's available regardless