2

I am using .net core 3.1 app. I would like to configure log4net loggigng mechanism properly. I did it before with .net framework. Can someone let me know what is the best approach?

Thank you in advance.

2
  • You can use this adapter BUT you should probably use a newer logging framework like Serilog or NLog. You can configure both of them with settings loaded from .NET Core's configuration instead of separate XML configuration files Commented Sep 18, 2020 at 11:31
  • 1
    @MarleneHE this question is pretty clear and doesn't depend on the type of application. .NET Core's logging middleware works the same in console, web app and library projects Commented Sep 18, 2020 at 11:33

1 Answer 1

6

I assume you have added log4net to you project with log4net.config file. In this case first you need to install package Microsoft.Extensions.Logging.Log4Net.AspNetCore. Next thing is to configure it in the middleware into the startup configure:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
       loggerFactory.AddLog4Net();
}

If you have any additional questions feel free to ask.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.