alexey-leonovich commented on issue #239: URL: https://github.com/apache/logging-log4net/issues/239#issuecomment-4477031792
@FreeAndNil I have exaclty the same exception with my MAUI 9 application and log4net 2.0.17 (I know it's pretty old but we cannot upgrade right now). I have log4net.config (same a used in my .net framewrok 4.7.2 application) which is MauiAsset: `<MauiAsset Include="..\Resto.Front.Main\Config\log4net.config" LogicalName="Config/log4net.config" />` The content of log4net.config is like: ``` <?xml version="1.0" encoding="utf-8"?> <!--<log4net xmlns="http://csharptest.net/downloads/schema/log4net.xsd" xsi:schemaLocation="http://csharptest.net/downloads/schema/log4net.xsd ..\..\..\ThirdParty\Net\log4net.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">--> <log4net> <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" > <applicationName value="myApp" /> <threshold type="log4net.Core.Level" value="FATAL" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="[%date{yyyy-MM-dd HH:mm:ss,fff}] %5p - %m%n" /> </layout> </appender> <appender name="FileAppender" type="log4net.Appender.FileAppender"> <threshold type="log4net.Core.Level" value="DEBUG" /> <file type="log4net.Util.PatternString" value="%property{LogFileDir}/main.log" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="[%date{yyyy-MM-dd HH:mm:ss,fff}] %5p [%2t] [%type{1}:%M] - %m%n" /> </layout> <AutoCompress value="true" /> <LogFileAgeDays value="90" /> <maximumFileSize value="1MB" /> </appender> <root> <level value="INFO" /> <appender-ref ref="EventLogAppender" /> <appender-ref ref="FileAppender" /> </root> </log4net> ``` And at runtime I copy it in temporary directory and apply it to log4net: ``` var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create); var configDir = Path.Combine(appData, "Config"); var configFileName = Path.Combine(configDir, "log4net.config"); if (!File.Exists(configFileName)) { Directory.CreateDirectory(configDir); using var assetStream = Android.App.Application.Context.Assets!.Open("Config/log4net.config"); using var fileStream = File.Create(configFileName); assetStream.CopyTo(fileStream); } ThreadContext.Properties["LogFileDir"] = Path.Combine(appData, "Logs"); XmlConfigurator.Configure(new Uri(configFileName)); ``` I have no App.Config file in my MAUI project. And exception is already in Visual Studio 2022 Output window by the moment I hit a breakpoint on the lat line of code above. What's whrong with my setup? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
