Updated to do less work if logging is disabled