| 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!!!
|