Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

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.

Subject: Log4Net used into Class library
Prev Next
You are not authorized to post a reply.

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.
Forums > Log4Net > Log4Net Mail archive > Log4Net used into Class library



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement