The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.
| Author |
Messages |
|
jeusdi
 |
| 02/05/2008 1:20 PM |
|
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-tp15289024p15289024.html Sent from the Log4net - Users mailing list archive at Nabble.com.
|
|
|
|
|
Radovan Raszka
 |
| 02/05/2008 2:09 PM |
|
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
|
|
|
|
|
|
| You are not authorized to post a reply. |
|
|
|
ActiveForums 3.7
|