Log only if neccessary to avoid redundant String construction.