I am trying to figure out how to configure Blazor and Serilog to be able to render a component that will display the log output on a razor page. I have searched extensively for an example specifically using Blazor/Asp.Net Core and have come up short.
If I have the following in my Startup:
myServiceCollection.AddLogging(l =>
{
l.ClearProviders();
l.AddConsole();
l.SetMinimumLevel(LogLevel.Debug);
});
And then in some other component I inject an ILogger how would I, instead of logging to the console, instead redirect the logs to some <textarea> or <p> that I have on the razor component in question? I basically just want to set up a log viewer page or be able to display the output of the logs on any arbitrary component.
While I have not found a specific example doing exactly what I am asking, there are an abundance of examples of Blazor chat apps using SignalR to do real-time chatting between users. My thought was that I could repurpose that and instead of having a chat app between users, I am just "chatting" between the server and the client where the messages are the outputted log lines. Would this be the best approach?