For Programmers: Free Programming Magazines  


Home > Archive > C# > January 2005 > Need Help With log4net









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Need Help With log4net
smartin_5321@yahoo.com

2005-01-20, 8:57 am

Hi!



I'm brand new to using log4net, and am getting the following error
when I try to run my test project:



log4net:ERROR DOMConfigurator: ConfigureFromXML called with null
'element' parameter



Needless to say, I am finding this quite frustrating, as I don't know
enough about log4net to really be able to debug properly.



The test project contains the following files:



using log4net;

using log4net.Config;



public class LogTest2

{

private static readonly ILog logger =
LogManager.GetLogger(typeof(LogTest2));



static LogTest2()

{

DOMConfigurator.Configure();

}



static void Main(string[] args)

{

logger.Debug("Here is a debug log.");

logger.Info("... and an Info log.");

logger.Warn("... and a warning.");

logger.Error("... and an error.");

logger.Fatal("... and a fatal error.");



}

}



<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

</configSections>

<log4net>

<appender name="LogFileAppender"
type="log4net.Appender.FileAppender">

<param name="File" value="LogTest2.txt" />

<param name="AppendToFile" value="true" />

<layout type="log4net.Layout.PatternLayout">

<param name="Header" value="[Header]\r\n" />

<param name="Footer" value="[Footer]\r\n" />

<param name="ConversionPattern" value="%d [%t]
%-5p %c - %m%n" />

</layout>

</appender>



<appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender" >

<layout type="log4net.Layout.PatternLayout">

<param name="Header" value="[Header]\r\n" />

<param name="Footer" value="[Footer]\r\n" />

<param name="ConversionPattern" value="%d [%t]
%-5p %c - %m%n" />

</layout>

</appender>



<root>

<level value="INFO" />

<appender-ref ref="LogFileAppender" />

<appender-ref ref="ConsoleAppender" />

</root>

</log4net>

</configuration>



The configuration file 'lives' in the main project directory.



I was really hoping that this would work, especially since I downloaded
it from a tutorial site. I made no changes to the code - just created
a new project and added the files.



Any help (or links to tutorials) would be greatly appreciated.
Thanks!!!

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com