Search code examples
.netazureloggingserilogazure-eventhub

How can I get .NET Console Logs from Azure App Service to Azure Event Hub?


I have a .NET 6 project writing application logs to Console using Serilog. The app is hosted on a Windows App Service.

Setup like this:

builder.Host.UseSerilog((ctx, lc) => lc
        .Enrich.FromLogC1ontext()
        .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate);

I have setup a Diagnostic Setting on the App Service to send the logs from Console Output to the Event Hub, but no console logs are sent to Event Hub.

I have also tried enabling HttpLogs, which work fine. So the trigger is working, but how do I get the stdout/Console logs to work?

enter image description here


Solution

  • Probably because, AppServiceConsoleLogs are not supported by .net windows application. Supported only for JavaSE and Tomcat.

    enter image description here