Problems with library
"Paul Ingles" <[email protected]> Thu, 13 Jan 2005 18:18:46 -0000
| Newsgroups | gmane.comp.windows.dotnet.log4net.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
This is my first attempt at wiring in log4net and I haven't had much luck
over the past few hours to get it working, so apologies if this is a
particularly dumb question. I've had a look through past posts and tried a
number of things but I can't seem to get log4net to load settings.
I have a library project where I'm actually trying to perform the logging.
The logger is loaded during the type's constructor as follows:
_log = LogManager.GetLogger(typeof(RelationImporter));
This library is then used by a master application that actually instantiates
this type. I've added the following declaration to this application's
configuration file:
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
And the section itself looks like this (apologies for the line lengths, but
its pretty standard -- I just want to log everything for the time being):
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="LogFileAppender"
type="log4net.Appender.FileAppender" >
<param name="File" value="log-file.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 [%x] %X{auth} - %m%n" />
</layout>
</appender>
<appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d
[%t] %-5p %c [%x] %X{auth} - %m%n" />
</layout>
</appender>
</log4net>
However, the logger retrieved through the LogManager appears not to be
configured -- IsInfoEnabled etc. are all set to false.
I then read it's possible to set it to load the configuration from a
separate file using an attribute for the assembly and so added the following
to my AssemblyInfo.cs file:
[assembly: log4net.Config.DOMConfigurator(ConfigFileExtension="log4net",
Watch=true)]
I then moved the config section above into an importer.log4net file and
placed it in the project output folder for the application. Again, nothing.
If anyone could suggest anything I'd be extremely grateful!
Incidentally, I'm using the latest beta (1.2.0-beta8) with Visual Studio
.NET 2003.
Thanks,
Paul
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt