logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Lund" <ml...@control4.com>
Subject RE: Wrapping Log4Net
Date Sat, 18 Jul 2009 21:22:12 GMT
Oops, I didn't quite finish one sentence below.  Meant to say "The
practical challenge was that I had to choose between only exposing
simple functionality in my wrapper to keep the coupling loose or
wrapping more of what NHibernate in order to take advantage of what it
offers but at the loss of loose coupling."


From: Matt Lund [mailto:mlund@control4.com] 
Sent: Saturday, July 18, 2009 3:20 PM
To: Log4NET User
Subject: RE: Wrapping Log4Net


This reminds me of my attempt to wrap our use of NHibernate.  I later
realized this was a bad idea for a practical reason and philosophical
reason.  The practical challenge was that I had to choose between only
exposing simple functionality in my wrapper to keep the coupling loose.
The philosophical epiphany we later had was that there is a difference
between services and frameworks.  Loosely coupling your program to
services is usually a good idea.  Loosely coupling your program to
frameworks is usually a bad idea.


In short, I'd reconsider wrapping it.


From: Peter Drier [mailto:peter.drier@gmail.com] 
Sent: Saturday, July 18, 2009 3:10 PM
To: Log4NET User
Subject: Re: Wrapping Log4Net


Because of "A", wrapping log4net is a bad idea.  It's a noble thought,
but in 10+ years of using log4net and having people around and above me
demand wrapping, I've never seen log4net replaced.   Given you can
always write an appender to output to any other system as necessary, the
"need" for wrapping is moot.  

B)  the only way to wrap it "better" would be to walk the stack
everytime something is logged to see who the calling method was..
Horribly slow, so I wouldn't call it better.

C) Some part of your config is wrong.  We log in release mode all the


On Sat, Jul 18, 2009 at 4:53 PM, xalex <alex@pixafe.com> wrote:

Hi forum,

I would like to use log4net in a large .net development. because i have
requirement to prepare a potential replacement of the log4net framework
against ms-enterprise library or against a newer version of log4net, i
like to wrap this. My way to do it is straight forward:
A single assembly references the log4net framework, offes the ILog and
LogManager classes, and all other projects reference only this wrapper

This wrapper allows me to restrict the users on only the main functions
which are really needed and allows me to replace this framework,

Now my question: When the ILog.Debug() Method is called, the output in
logfile is wrong, because the LocationInfo used for this output
to the Wrapper and not to the code from which it is really called :-(

A: Is there an easy way to fix this problem?
B: Is there a better idea to wrap log4net
C: Is it true, that logging is only possible in DEBUG-Builds? When using
release build, i dont get any output


   public interface ILog
       bool IsDebugEnabled { get; }
       bool IsErrorEnabled { get; }
       bool IsFatalEnabled { get; }
       bool IsInfoEnabled { get; }
       bool IsWarnEnabled { get; }

       void Debug(object message);
       void Error(object message);
       void Fatal(object message);
       void Info(object message);
       void Warn(object message);

   public static class LogManager
       static LogManager()
           XmlConfigurator.Configure( new
System.IO.FileInfo("c:/logger.xml")) ;

       public static ILog GetLogger(Type type)
           MyLog log = new MyLog(log4net.LogManager.GetLogger(type) );
           return log;

   public class MyLog :ILog
       private log4net.ILog _log;

       public MyLog(log4net.ILog log)
           _log = log;

       #region ILog Members

       public bool IsDebugEnabled
           get { return _log.IsDebugEnabled; }

       public void Debug(object message)


View this message in context:
Sent from the Log4net - Users mailing list archive at Nabble.com.


View raw message