To enable stdout logging for an Azure .NET Core app running from a package, follow these steps:
- In the Azure portal, navigate to your App Service.
- Go to the Configuration tab.
- Under the Application settings section, add or update the following settings:
ASPNETCORE_ENVIRONMENT
: Set the value toDevelopment
or any other non-production environment name.WEBSITE_RUN_FROM_PACKAGE
: Set the value to1
.
- Under the General settings section, set Web sockets to
On
. - Save the changes.
Next, modify your Program.cs
file in your .NET Core app to configure the logger:
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
});
});
}
This configuration will enable stdout logging for your Azure .NET Core app running from a package.