Fix logger.isTraceEnabled check before the last logger.trace. And extract an traceEnabled variable for reuse.

Comment From: sbrannen

Thanks for the PR.

For these particular use cases, we don't think there is much benefit in applying the proposed changes. If trace logging becomes a performance issue, we might revisit whether we need to trace logging at all.

In light of that, I am closing this PR.

Comment From: chenqimiao

@sbrannen I get it, thank you for your pointing.