You must configure logging system first:

log4net.Config.XmlConfigurator.Configure(new
System.IO.FileInfo("mypath/to/log4net.xml"));
// after configuring you can get logger instance
logger = log4net.LogManager.GetLogger(typeof(OnCloseSessionManager))

If you can not configure log4net using XmlConfiguratorAtttribute, check
if config file is on the expected path (in the same directory as your
assembly)
R

-----Original Message-----
From: jeusdi [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 05, 2008 1:21 PM
To: [email protected]
Subject: Log4Net used into Class library


I'm develping a little library, and I'm adding log features to it, now.
The problem is that I don't know How I Can configure Log4Net. In my code
I obtain a logger as:

private log4net.ILog logger =
log4net.LogManager.GetLogger(typeof(OnCloseSessionManager))

but, when I need to use it (the logger), it is null.

I also have this line in my code:
[assembly: log4net.Config.XmlConfigurator(ConfigFile="log4net.xml",
Watch=true)]
but, the logger is null, yet. The beliee that this line find around the
application directory files as log4net.xml and configure the logs using
this xml file...

The log4net.xml file of my application (application that uses my class
library) is:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
     <appender name="exceptions" type="log4net.Appender.FileAppender">
         <file value="./exceptions.log" />
         <lockingModel type="log4net.Appender.FileAppender+MinimalLock"
/>
         <appendToFile value="true" />
         <layout type="log4net.Layout.PatternLayout">
             <conversionPattern value="%date %level %thread %logger -
%message%newline" />
         </layout>
     </appender>
     <root>
         <level value="ALL" />
         <appender-ref ref="exceptions" />
     </root>
</log4net>

Can you help me please?
I will appreciate a lot your help.
Thanks for all.
--
View this message in context:
http://www.nabble.com/Log4Net-used-into-Class-library-tp15289024p1528902
4.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Reply via email to