huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore

Blazor Client support

Opened this issue · 0 comments

We are trying to re-use our C# business layer in Blazor, our business layer is more a 'smart object' CSLA structure and we tied it to log4net. It requires the frontend to have it configured and the backend to have it configured. One solution is to remove log4net where ever possible and then use default logproviders or else Serilog.

I'm however looking at solutions that require less work, perhaps using this package. It works for .NET Core and blazor server side only. It would require us to implement a facade from Blazor Client to Blazor Server and then from Blazor Server we can use our existing business layer which communicates to another server again.. I rather use our business layer inside Blazor Client for calling the server.

However i get exceptions like

System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.PlatformNotSupportedException: Operation is not supported on this platform

I notice that this package doesn't use the Configuration, but configures to load a xml in the startup.
So I tried it...

loggerFactory.AddLog4Net("log4Net.xml");

Is it intended to work in Blazor Client? Could it work? This doesn't work, but maybe if there is something modified or in a new version?

    public static async Task Main(string[] args)
    {
        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("app");
        builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        ...

        builder.Logging.AddLog4Net("log4Net.xml");

        await builder.Build().RunAsync();
    }

throws error:

image