Fixed error when logging is enabled