You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Alex Henderson <al...@bittercoder.com> on 2004/06/06 14:45:11 UTC

Appender config is not being loaded?

Hi All..

I've just started to attempt using log4net in a project - I have this config
(btw, I'm using version log4net 1.1.1)

	<!-- log4net config section -->
	<log4net debug="true">
		<appender name="LogFileAppender"
type="log4net.Appender.FileAppender,log4net" >
			<param name="File" value="C:\\logs\\yortle.service.log" />
			<param name="AppendToFile" value="true" />
			<layout type="log4net.Layout.PatternLayout,log4net">
				<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
			</layout>
		</appender>
		<root>
			<priority value="DEBUG" />
			<appender-ref ref="LogFileAppender" />
		</root>
	</log4net>

..now I get an error when initialising log4net, stating that no Appender
with the name "LogFileAppender" exists... I've done some exploration and the
issue seems to be that when the DOMConfigurator enters the method:

	protected IAppender FindAppenderByReference(XmlElement appenderRef)

It eventually gets here (below) and bails out because no elements are
returned to loop through:

	foreach (XmlNode node in
appenderRef.OwnerDocument.GetElementsByTagName(APPENDER_TAG)) // <----
	{
		if (((XmlElement)node).GetAttribute("name") == appenderName)
		{
			element = (XmlElement)node;
			break;
		}
	}

On further inspection it seems that the ".OwnerDocument" has no child
elements at all... which cant be right if appenderRef exists at all I
would've thought?

Oh yeah, this is how I am initialising and calling log4net at the moment -
currently it's just part of a unit test spike before I stick it throughout
my code.

[TestFixture] public class LogTests
{
	public LogTests()
	{
	}

	[Test] public void TestLoggingToFile()
	{
		log4net.Config.DOMConfigurator.Configure();
		log4net.ILog log = log4net.LogManager.GetLogger(typeof(LogTests));
		log.Debug("this is a debug message");
		log.Info("this is a info message");
		log.Error("this is an error message");
		log.Fatal("this is a fatal message");
		log.Warn("this is a warning message");
	}
}

Any help would be greatly appreciated!

Cheers,

 - Alex