When you use ILogger or Console.WriteLine in WebAssembly the logs are written in the browser console. But in the Blazor Server apps the logs don't appear in the browser console. I want to see the logs in the browser console (because it's very useful) while I debugging the app.
You can invoke the console via JsInteropt:
<button @onclick=@(()=>ConsoleLog("Hello")) >Hello</button>
@code {
[Inject]
public IJSRuntime JSRuntime { get; set; }
public async void ConsoleLog(string message)
{
await JSRuntime.InvokeVoidAsync("console.log", message);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.