'Capturing errors in hosted Blazor Web Assembly app

I have a .net Hosted Blazor Web Assembly app (the one that generates 3 projects, Client (Blazor Web Assembly project), Server (Web API Server project), Shared.

How can I log errors on the server app? In regular .net Core apps I'd add something like this to the web.config for it to store errors in the Logs folder:

<aspNetCore arguments="" stdoutLogEnabled="true" hostingModel="InProcess" stdoutLogFile=".\logs\stdout">
</aspNetCore>

However, this doesn't work in the web.config file that Publish generates in the hosted Blazor app.

I found this file, but it doesn't suggest how to debug the Server project on the server: https://docs.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-6.0&tabs=visual-studio

I've googled this and can't find how to get the errors from the Server app. Ideally some kind of error emailed to me would be ideal but logs in a folder would be OK.

Thanks



Solution 1:[1]

You need to use some third party library like NLog.
Blazor server log works exactly like Asp.net core. See this link about using Nlog

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user13256346