Move variable assignment within logging block.
Merge pull request #16807 from tgxworld/carry_out_assignment_within_block

Move variable assignment within logging block.