How can I capture logs from .net WebHost in our own logger?

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()
            .UseHttpSys(options =>
                options.Authentication.Schemes = AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate;
                options.Authentication.AllowAnonymous = true;
                options.MaxConnections = -1;
                options.MaxAccepts = Environment.ProcessorCount * 2;
            .ConfigureServices(services => { services.AddSingleton(_startUpConfig); })


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

Pretty straight forward actually, as I expected.
Thank you Microsoft 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x