From db72096d1716d8d789290a1f89f1a2e81fc2e74e Mon Sep 17 00:00:00 2001 From: ivberg Date: Tue, 5 Nov 2024 09:51:26 -0800 Subject: [PATCH] Revert to err logging instead of LOGS_DEFAULT macro (#22720) Revert to err logging instead of LOGS_DEFAULT macro due to issue seen during testing. "onnxruntime::logging::LoggingManager::DefaultLogger Attempt to use DefaultLogger but none has been registered." ### Description Revert part of PR suggestion to prevent crash for scenario seen in #22699. Previously we had tested w/o this macro ### Motivation and Context Previous PR #22699 it was suggested to use LOGS_DEFAULT() but that does not work during early init. Safer to use std::cerr instead like the original PR had it. --- onnxruntime/core/platform/windows/logging/etw_sink.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/onnxruntime/core/platform/windows/logging/etw_sink.cc b/onnxruntime/core/platform/windows/logging/etw_sink.cc index 9e58b79c36..950ac247a2 100644 --- a/onnxruntime/core/platform/windows/logging/etw_sink.cc +++ b/onnxruntime/core/platform/windows/logging/etw_sink.cc @@ -160,7 +160,9 @@ void EtwRegistrationManager::LazyInitialize() { if (FAILED(etw_status_)) { // Registration can fail when running under Low Integrity process, and should be non-fatal initialization_status_ = InitializationStatus::Failed; - LOGS_DEFAULT(WARNING) << "Error in ETW registration: " << std::to_string(etw_status_); + // Injection of ETW logger can happen very early if ETW provider was already listening. + // Don't use LOGS_DEFAULT here or can get "Attempt to use DefaultLogger but none has been registered" + std::cerr << "Error in ETW registration: " << std::to_string(etw_status_) << std::endl; } initialization_status_ = InitializationStatus::Initialized; }