huorswords / Microsoft.Extensions.Logging.Log4Net.AspNetCore

Allows to configure Log4net as Microsoft Extensions Logging handler on any ASP.NET Core application. Original code proposal by @anuraj --> https://dotnetthoughts.net/how-to-use-log4net-with-aspnetcore-for-logging/
Apache License 2.0
247 stars 121 forks source link

Does not work with new .NET core 2.2 inproc hosting model #51

Closed shorbachuk closed 5 years ago

shorbachuk commented 5 years ago

I am trying to use the new .NET core 2.2 inprocess hosting model, however this package is trying to load log4net.config from the wrong path:

Application startup exception: System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\log4net.config'.

https://blogs.msdn.microsoft.com/webdev/2018/09/12/asp-net-core-2-2-0-preview2-now-available/

huorswords commented 5 years ago

Hello @shorbachuk ,

Thank you very much by open the issue.

I have uploaded a new branch within a sample that I hopefully configured to run within the netcore 2.2 preview version, and using a small modification that I have introduced in the code in order to test the scenario you are trying to arrange.

Could you clone this repository on your local, branch feature/51, and review the sample called Sample.WebApi_NetCore22 in order to:

Let me know the results, as per my tests on my local, the resolution is working properly.

Thank you.

shorbachuk commented 5 years ago

I did look at the changes and I think that would fix it. I should have some time tomorrow to test it out and let you know.

huorswords commented 5 years ago

Thank you very much @shorbachuk . I will wait until you can test it properly. Let me know the results.

shorbachuk commented 5 years ago

Unfortunately, it still does not work. Still picking up the path for the IIS path. It looks like Path.Combine(AppContext.BaseDirectory, "log4net.config") is the only thing I can find that resolves properly.

huorswords commented 5 years ago

Branch updated. Can you test it again? Sorry by the inconveniences.

shorbachuk commented 5 years ago

This one works hosted inprocess in IIS. Did not test out of process, but looks good thank you.

huorswords commented 5 years ago

Hi @shorbachuk ,

Now the fix is included on v.2.2.6 (https://www.nuget.org/packages/Microsoft.Extensions.Logging.Log4Net.AspNetCore/2.2.6)

Thank you by your time.