diff --git a/LogMonitor/src/LogMonitor/LogFileMonitor.cpp b/LogMonitor/src/LogMonitor/LogFileMonitor.cpp index fbf1427..7ef7c8c 100644 --- a/LogMonitor/src/LogMonitor/LogFileMonitor.cpp +++ b/LogMonitor/src/LogMonitor/LogFileMonitor.cpp @@ -701,13 +701,21 @@ LogFileMonitor::InitializeDirectoryChangeEventsQueue() nullptr); if (logFile == INVALID_HANDLE_VALUE) { - logWriter.TraceError( - Utility::FormatString( - L"Error in log file monitor. Failed to open file %ws. Error = %d", - fileName.c_str(), - GetLastError() - ).c_str() - ); + // + // Added a conditional check to suppress logging for ERROR_NOT_SUPPORTED (benign error). + // This prevents unnecessary log pollution while still logging other actionable errors. + // https://github.com/microsoft/windows-container-tools/issues/125#issuecomment-3056545183 + // + if (GetLastError() != ERROR_NOT_SUPPORTED) + { + logWriter.TraceError( + Utility::FormatString( + L"Error in log file monitor. Failed to open file %ws. Error = %d", + fileName.c_str(), + GetLastError() + ).c_str() + ); + } // // Ignore failure and continue. In the worst case we will @@ -1079,13 +1087,19 @@ LogFileMonitor::LogFileAddEventHandler( if (status != ERROR_SUCCESS) { status = GetLastError(); - logWriter.TraceError( - Utility::FormatString( - L"Error in log file monitor. Failed to query file ID. File: %ws. Error: %d", - fullLongPath.c_str(), - status - ).c_str() - ); + // Added a conditional check to suppress logging for ERROR_NOT_SUPPORTED (benign error). + // This prevents unnecessary log pollution while still logging other actionable errors. + // https://github.com/microsoft/windows-container-tools/issues/125#issuecomment-3056545183 + if (status != ERROR_NOT_SUPPORTED) + { + logWriter.TraceError( + Utility::FormatString( + L"Error in log file monitor. Failed to query file ID for File: %ws. Error: %d", + fullLongPath.c_str(), + status + ).c_str() + ); + } } status = ReadLogFile(logFileInfo);