There is proopably some simple answer this but after trawling the internet for hours, I have not yet found an answer
We have our own implementation of a logging-system
We would like to capture the information logged in WebHost in our own logger
But how do I direct the logs produced in WebHost to our logger?
Our webhost is pretty standard, if that makes any difference
We are building to .net 5
_host = new WebHostBuilder() .AddHttpListener(_startUpConfig) .UseHttpSys(options => { options.Authentication.Schemes = AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate; options.Authentication.AllowAnonymous = true; options.MaxConnections = -1; options.MaxAccepts = Environment.ProcessorCount * 2; }) .UseUrls($"{_url}://+:{PortNo}/") .UseUnityServiceProvider(IocContainer) .ConfigureServices(services => { services.AddSingleton(_startUpConfig); }) .UseStartup<StartUp>() .Build();
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
After trawling the internet even more, I finally came across the answer
Microsoft has actually nicely produced a document on how to add your own custom logger
https://docs.microsoft.com/en-us/dotnet/core/extensions/custom-logging-provider
Pretty straight forward actually, as I expected.
Thank you Microsoft 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0