i'm developing a simple .NET application and i'm tryng to use log4Net to log some usefull info. With the basic configuration i have no problem. When i try to use an xml configuration i have the following problem:
log4net:ERROR Error while loading XML configuration System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String arg) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at log4net.Config.XmlConfigurator.InternalConfigure(ILoggerRepository repository, Stream configStream)
The piece of code is the following:
var xmlConfig = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location+path.DirectorySeparatorChar+"logConfig.xml");
if (xmlConfig != null) XmlConfigurator.Configure(new FileInfo(xmlConfig));
else BasicConfigurator.Configure();
The xml file is taked directly from log4net documentation and is the following
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
how can i solve that error, i think the xml is correct assuming there is no error in documentation.