DDF-324 check if trace is enabled to improve logging performance.