Reputation: 156
I need to use log4net on a new Asp.net Core app. I get FileNotFoundException error when I run the project.
Startup.cs
ConfigureServices method:
services.AddLogging(builder =>
{
builder.AddConfiguration(Configuration.GetSection("Logging"))
.AddConsole()
.AddDebug();
});
Configure Method:
loggerFactory.AddLog4Net("log4net.config");
I get the error on this line. Log4net.config file is in the UI project.
Why am I getting this error?
Upvotes: 0
Views: 735
Reputation: 156
Thanks for your help. I've solved this problem. I changed the copy to output directory property for log4net.config file to copy always.
Upvotes: 1
Reputation: 182
Could you change your configure method with this;
log4netConfig.Load(File.OpenRead("log4net.config"));
Upvotes: 0