4
votes

I have the following log from the log4net debug log:

log4net: DefaultRepositorySelector: repository [log4net-default-repository] already exists, using repository type [log4net.Repository.Hierarchy.Hierarchy] log4net: XmlConfigurator: configuring repository [log4net-default-repository] using file [log4net.config] watching for file updates log4net: XmlConfigurator: configuring repository [log4net-default-repository] using file [log4net.config] log4net: XmlConfigurator: configuring repository [log4net-default-repository] using stream log4net:ERROR XmlConfigurator: Error while loading XML configuration System.Xml.XmlException: ' ' is an unexpected token. The expected token is '>'. Line 7, position 184. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2) at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(Int32 pos, String expectedToken1, String expectedToken2) at System.Xml.XmlTextReaderImpl.ParseAttributes() at System.Xml.XmlTextReaderImpl.ParseElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Xml.XmlValidatingReaderImpl.Read() at System.Xml.XmlValidatingReader.Read() at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at log4net.Config.XmlConfigurator.Configure(ILoggerRepository repository, Stream configStream)

The only problem is, I have no idea where it thinks it's getting this log4net.config file, since in my AssemblyInfo.cs I have defined it to be:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "api4net.config", Watch = true)]

Is there an easy way to determine where log4net is loading this mystical log4net.config that has some xml errors?

1
If this is a web app it will expect that file to be in the web root.dotjoe
dotjoe, you're right. It looks like it was checking out my web.config and finding some xml parse error somehow. My setup was all wrong, and I didnt have a global.asax file to configure the startup. The answer was found on the link below. Thanks for the tip. stackoverflow.com/questions/2446556/…Mike
cool. For future reference I find the ConfigureAndWatch method much nicer than adding crap to AssemblyInfo.cs. Just add this to Application_Start...log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Server.MapPath("~/log4net.config")));dotjoe

1 Answers

0
votes

I thought one should config the appenders in the app.config or in the web.config. but i am log4net newbie. phil haack wrote:

If you use a separate config file, a quick and easy (and dirty) way to have your application find it is to place the config file in the webroot ...