FileStream 与 log4net.Repository.ILoggerRepository UWP 之间的转换

Conversion between FileStream and log4net.Repository.ILoggerRepository UWP

您好,我在 UWP 中配置 log4net 时遇到问题,因为当我尝试这样做时,我发现无法将 FileInfo 转换为 ILoggerRepository

public MainPage()
        {
            XmlConfigurator.Configure(new FileInfo(Path.GetFileName("C:\Users\kamil\source\repos\Trader\Trader\Assets\sample.xml")));
            this.InitializeComponent();
            ApiHelper.InitializeClient();
    }

XmlConfigurator.Configure(FileInfo configFile) 仅在 .net 框架中可用。您应该使用 XmlConfigurator.Configure(ILoggerRepository repository, FileInfo configFile) 以使其在您的应用程序中工作。这是一个例子:

ILoggerRepository loggerRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
FileInfo fileInfo = new FileInfo(Path.GetFileName(@"C:\Path\To\Source\sample.xml"));

XmlConfigurator.Configure(loggerRepository, fileInfo);

完整文档:XmlConfigurator.cs