In all the example documentation I've seen, the <root> element of the config is defined after the <appender> definitions. I don't know why this would make a difference, but maybe try that and see if it makes any difference.
I can't see anything obviously wrong with your code or config. -----Original Message----- From: Patrick [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 17, 2004 5:40 AM To: [email protected] Subject: ERROR: No appender named [A] could be found I have downloaded Log4net 1.1.1 at http://prdownloads.sourceforge.net/log4net/log4net_1_1_1.zip?use_mirror=ovh I can't even get the TestApp example working (I have stripped it down and still no joy!). I note that the sample app does not have a config file in there. So here is what I did 1) Extracted zip file to c:\ 2) Add reference to c:\ c:\log4net_1_1_1\bin\log4net.dll to the Visual Studio project c:\log4net_1_1_1\example\TestApp\TestApp.csproj 3) Source file and config file at the end of this posting 4) Compiled the testapp project when I run the app, I get the following displayed on the console log4net:ERROR No appender named [A] could be found. log4net:ERROR No appender named [B] could be found. log4net:ERROR No appenders could be found for category (MainApp). log4net:ERROR Please initialize the log4net system properly. I am running Windows XP Professional SP1, .NET Framework 1.1, Visual Studio .NET 2003 Enterprise Architect. I note that if instead of adding reference to the dll distributed with the installation, I 1) Add project c:\log4net_1_1_1\src\log4net.csproj to the VS solution 2) Add project reference to log4net.csproj (instead of log4net.dll) 3) recomplie 4) As I debug, I found out that on the following line 421 of Config\DOMConfigurator.cs 4.1) a quick watch on appenderRef.OwnerDocument.GetElementsByTagName("appender").Count returns 0! 4.2) a quick watch on appenderRef.OwnerDocument.OuterXml returns "" 4.3) a quick watch on appenderRef.paretnNode.OuterXml returns "<root>\r\n<level value=\"DEBUG\" />\r\n<appender-ref ref=\"A\" />\r\n<appender-ref ref=\"B\" />\r\n</root>" Line 421: appenderRef.OwnerDocument.GetElementsByTagName(APPENDER_TAG) I don't understand why? We got the same code, this surely is just XML, why is mine not reading the XML properly?? Did you have to do anything else other other than compiling the sourcecode and app.config you posted? *******************************Start of App.Config******************************* <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <log4net> <root> <level value="DEBUG" /> <appender-ref ref="A" /> <appender-ref ref="B" /> </root> <appender name="B" type="log4net.Appender.FileAppender"> <param name="File" value="log-file.txt" /> <param name="AppendToFile" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n" /> </layout> </appender> <appender name="A" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n" /> </layout> </appender> </log4net> </configuration> *******************************End of App.Config******************************* *******************************Start of MainApp.cs******************************* class MainApp { //Initialise log to log4net.LogManager.Root makes no difference- still ERROR private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod() .DeclaringType); public MainApp() { } /// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { log4net.Config.DOMConfigurator.Configure(); if(log.IsInfoEnabled) { log.Info("logging start!"); } } } *******************************End of MainApp.cs*******************************
