Here is a simple configuration without using dependency injection - for that there is a dedicated NuGet package. This is most useful if some dependent library is using log4net, while the main application may use other logging library.
public static class Log4NetSetup
{
public static void SetLog4NetConfiguration()
{
XmlDocument log4netConfig = new ();
log4netConfig.Load(File.OpenRead("log4net.config"));
var repo = LogManager.CreateRepository(
Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));
log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);
}
}