1

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://learn.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

1 Answer 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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I never had to use this with .net core MVC though. It could write errors to a log file (stdout) setup in web.config- or the home controller had an error handler already setup…
I got what you mean but this my way :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.