I am new to asp.net core 2.0. I creating a webapi and want to configure log4net as my logging provider.
I couldn't find some working example in net. Can anyone help me provide the right link or some sample code about how to properly setup log4net in asp.net core 2.0
Things i have done so far is as below and i am not sure how to proceed further.
installed log4net.Extensions.AspNetCore;
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
loggerFactory.AddLog4Net();
// Enable CORS
app.UseCors(builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
app.UseMvc();
}
NET Core. To use log4net from . NET core, you need to install at least version 2.0.
yes. Log4Net targets . NET Standard, which gives it a level of compatibility across the entirety of . NET core, including .
Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
call loggerFactory.AddLog4Net();
More info -> https://github.com/huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With