I have created a simple ASP.NET Core 3.1 WebAPI project in Visual Studio 2022.
I want to log any errors. I have been following this post https://github.com/MicrosoftDocs/azure-docs/issues/31380.
First I added a webconfig.config to the project and added the following to enable logging:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile="\LogFiles\stdout"></aspNetCore>
</system.webServer>
</configuration>
I then created a folder on my FTP server to store the LogFiles in the publish folder and set the write permissions to 644.
I have also added the following to the Program.cs class:
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.CaptureStartupErrors(true)
.UseSetting("detailedErrors", "true");
});
I did edit the WebAPI.csproj file to enable the OutOfProcess hosting model to allow more than one project to run on separte subdomains.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
When I access the API in the browser the log files are not created even if there is a startup error.
Does anyone have any experience of getting this working on 1&1 IONOS Windows Hosting packages?