dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.02k stars 4.67k forks source link

No LogInformation is written. #108239

Open skorczyk opened 1 day ago

skorczyk commented 1 day ago

Describe the bug

No LogInformation is written.

To Reproduce

In the following code no logInformationMessage in method WorkThroughInvoiceFiles() is written.

using Microsoft.Extensions.Logging;

namespace ProofOfPerformanceInvoiceMatch
{
    internal class InvoiceFilesInvestigation(ILogger<InvoiceFilesInvestigation> logger)
    {
        private List<string>? invoiceFilesNameAndPathList;

        public InvoiceFilesInvestigation(ILogger<InvoiceFilesInvestigation> logger, List<string>? invoiceFilesNameAndPathList) : this(logger)
        {
            this.invoiceFilesNameAndPathList = invoiceFilesNameAndPathList;
        }

        internal void WorkThroughInvoiceFiles()
        {
            string logInformationMessage;
            logInformationMessage = "Untersuche die Rechnungen";
            logger.LogInformation(logInformationMessage);
            foreach (string oneInvoiceFilesNameAndPath in invoiceFilesNameAndPathList)
            {
                logInformationMessage = "PDF-Datei »" + oneInvoiceFilesNameAndPath + "«";
                logger.LogInformation(logInformationMessage);
            }
        }
    }
}
      Untersuche die Rechnungen
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00024_AN1000236287_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00025_AN1000236292_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00026_AN1000236293_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00027_AN1000236294_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00028_AN1000236296_b-next engineering GmbH.PDF«

H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\ProofOfPerformanceInvoiceMatch.exe (Prozess "5152") wurde mit Code "0" (0x0) beendet.
Um die Konsole beim Beenden des Debuggens automatisch zu schließen, aktivieren Sie "Extras" > "Optionen" > "Debuggen" > "Konsole beim Beenden des Debuggings automatisch schließen".
Drücken Sie eine beliebige Taste, um dieses Fenster zu schließen.

It works on Docker.

proofofperformanceinvoicematch01  |       Untersuche die Rechnungen
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00030_AN1000236298_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00026_AN1000236293_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00025_AN1000236292_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00027_AN1000236294_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00028_AN1000236296_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00029_AN1000236297_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Rechnungen/RGRG+24-1-00024_AN1000236287_b-next engineering GmbH.PDF«
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.ProofOfPerformanceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       Untersuche die Leistungsnachweise
proofofperformanceinvoicematch01  | info: ProofOfPerformanceInvoiceMatch.ProofOfPerformanceFilesInvestigation[0]
proofofperformanceinvoicematch01  |       PDF-Datei »/app/Leistungsnachweise/b-next Leistungsnachweis_Projekt BaFin_Vertragserweiterung_2021 0655-001.pdf«
proofofperformanceinvoicematch01 exited with code 0
PS H:\source\repos\ProofOfPerformanceInvoiceMatch>

If I add System.Threading.Thread.Sleep(1) it works on Windows platform

      internal void WorkThroughProofOfPerformanceFiles()
      {
          System.Threading.Thread.Sleep(1);
          string logInformationMessage;
          logInformationMessage = "Untersuche die Leistungsnachweise";
          logger.LogInformation(logInformationMessage);
          foreach (string oneProofOfPerformanceFilesNameAndPath in proofOfPerformanceFilesNameAndPathList)
          {
              logInformationMessage = "PDF-Datei »" + oneProofOfPerformanceFilesNameAndPath + "«";
              logger.LogInformation(logInformationMessage);
          }
      }
      Untersuche die Rechnungen
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00024_AN1000236287_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00025_AN1000236292_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00026_AN1000236293_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00027_AN1000236294_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00028_AN1000236296_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00029_AN1000236297_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.InvoiceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Rechnungen\RGRG+24-1-00030_AN1000236298_b-next engineering GmbH.PDF«
info: ProofOfPerformanceInvoiceMatch.ProofOfPerformanceFilesInvestigation[0]
      Untersuche die Leistungsnachweise
info: ProofOfPerformanceInvoiceMatch.ProofOfPerformanceFilesInvestigation[0]
      PDF-Datei »H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\Leistungsnachweise\b-next Leistungsnachweis_Projekt BaFin_Vertragserweiterung_2021 0655-001.pdf«

H:\source\repos\ProofOfPerformanceInvoiceMatch\ProofOfPerformanceInvoiceMatch\bin\Debug\net8.0\ProofOfPerformanceInvoiceMatch.exe (Prozess "6996") wurde mit Code "0" (0x0) beendet.
Um die Konsole beim Beenden des Debuggens automatisch zu schließen, aktivieren Sie "Extras" > "Optionen" > "Debuggen" > "Konsole beim Beenden des Debuggings automatisch schließen".
Drücken Sie eine beliebige Taste, um dieses Fenster zu schließen.

Further technical details

PS C:> dotnet --info .NET SDK: Version: 8.0.401 Commit: 811edcc344 Workload version: 8.0.400-manifests.251308be MSBuild version: 17.11.4+37eb419ad

Runtime Environment: OS Name: Windows OS Version: 10.0.20348 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.401\

.NET workloads installed: Configured to use loose manifests when installing new manifests. [maui-windows] Installation Source: VS 17.11.35312.102 Manifest Version: 8.0.82/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.82\WorkloadManifest.json Install Type: FileBased

[maccatalyst] Installation Source: VS 17.11.35312.102 Manifest Version: 17.5.8030/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.5.8030\WorkloadManifest.json Install Type: FileBased

[ios] Installation Source: VS 17.11.35312.102 Manifest Version: 17.5.8030/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.5.8030\WorkloadManifest.json Install Type: FileBased

[android] Installation Source: VS 17.11.35312.102 Manifest Version: 34.0.113/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.113\WorkloadManifest.json Install Type: FileBased

[wasm-tools-net6] Installation Source: VS 17.11.35312.102 Manifest Version: 8.0.8/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net6\8.0.8\WorkloadManifest.json Install Type: FileBased

[wasm-tools-net7] Installation Source: VS 17.11.35312.102 Manifest Version: 8.0.8/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net7\8.0.8\WorkloadManifest.json Install Type: FileBased

[wasm-tools] Installation Source: VS 17.11.35312.102 Manifest Version: 8.0.8/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.8\WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.8 Architecture: x64 Commit: 08338fcaa5

.NET SDKs installed: 8.0.400 [C:\Program Files\dotnet\sdk] 8.0.401 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download PS C:>

Microsoft Visual Studio Professional 2022 Version 17.11.4 VisualStudio.17.Release/17.11.4+35312.102 Microsoft .NET Framework Version 4.8.09037

Installierte Version: Professional

Visual C++ 2022 00483-10902-10922-AA422 Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.11.231.19466 ASP.NET and Web Tools

Azure App Service-Tools v3.0.0 17.11.231.19466 Azure App Service-Tools v3.0.0

Azure Functions and Web Jobs Tools 17.11.231.19466 Azure Functions and Web Jobs Tools

C#-Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9 C#-Komponenten, die in der IDE verwendet werden. Abhängig von Ihrem Projekttyp und den zugehörigen Einstellungen kann eine andere Version des Compilers verwendet werden.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Dotfuscator Community Edition 6.5.3+7f0b0a9d18 PreEmptive Protection - Dotfuscator CE

Extensibility Message Bus 1.4.39 (main@e8108eb) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.11.3 (ba13144) Support for debugging Mono processes with Visual Studio.

Node.js-Tools 1.5.60329.1 Commit Hash:15fce86a17f9f33e5bd7ca7ccb9b216aff149252 Fügt Unterstützung für das Entwickeln und Debuggen von Node.js-Apps in Visual Studio hinzu

NuGet-Paket-Manager 6.11.0 NuGet-Paket-Manager in Visual Studio. Weitere Informationen zu NuGet finden Sie unter https://docs.nuget.org/.

Razor (ASP.NET Core) 17.11.3.2442001+68650a7d94261bc56a1f4bc522c2ee35314b1abb Stellt Sprachdienste für ASP.NET Core Razor bereit.

SQL Server Data Tools 17.11.47.0 Microsoft SQL Server Data Tools

TypeScript-Tools 17.0.30715.2002 TypeScript-Tools für Microsoft Visual Studio

Visual Basic-Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9 Visual Basic-Komponenten, die in der IDE verwendet werden. Abhängig von Ihrem Projekttyp und den zugehörigen Einstellungen kann eine andere Version des Compilers verwendet werden.

Visual F# Tools 17.11.0-beta.24421.7+af2f522de602281d4ef5a7b71507c428e814c5c1 Microsoft Visual F# Tools

VisualStudio.DeviceLog 1.0 Informationen zum Paket

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

VSPackage-Erweiterung 1.0 Detaillierte Informationen zur VSPackage Visual Studio-Erweiterung

Xamarin 17.11.0.98 (d17-11@86652fe) Visual Studio-Erweiterung, um Entwicklung für Xamarin.iOS und Xamarin.Android zu ermöglichen.

Xamarin Designer 17.11.3.11 (remotes/origin/d17-11@cdbb0a4fdd) Visual Studio-Erweiterung zum Aktivieren der Xamarin Designer-Tools in Visual Studio.

Xamarin Templates 17.9.0 (38e87ba) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14) Xamarin.Android Reference Assemblies and MSBuild support. Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Xamarin.iOS and Xamarin.Mac SDK 16.4.0.23 (9defd91b3) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

baronfel commented 1 day ago

Since this is a question about the behavior of the Microsoft.Extensions.Logging library, I'm moving this to runtime.

tarekgh commented 1 day ago

@skorczyk could you please share a compliable project reproduce your issue? We need to know which logger you are using. Thanks!

skorczyk commented 11 hours ago

ProofOfPerformanceInvoiceMatch.zip