Return-Path: Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: (qmail 48486 invoked from network); 18 Jul 2009 21:21:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jul 2009 21:21:39 -0000 Received: (qmail 33830 invoked by uid 500); 18 Jul 2009 21:22:44 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 33759 invoked by uid 500); 18 Jul 2009 21:22:44 -0000 Mailing-List: contact log4net-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET User" List-Id: Delivered-To: mailing list log4net-user@logging.apache.org Received: (qmail 33750 invoked by uid 99); 18 Jul 2009 21:22:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Jul 2009 21:22:44 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [204.246.145.15] (HELO c4mail01.control4.com) (204.246.145.15) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Jul 2009 21:22:34 +0000 Received: from c4mail02.control4.com ([10.11.16.18]) by c4mail01.control4.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 18 Jul 2009 15:22:13 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01CA07ED.D0F723CA" Subject: RE: Wrapping Log4Net Date: Sat, 18 Jul 2009 15:22:12 -0600 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Wrapping Log4Net Thread-Index: AcoH7C0kqWuk8C63SpWYzd4Dt0tGawAAL1dwAAAq5WA= References: <24551728.post@talk.nabble.com> From: "Matt Lund" To: "Log4NET User" X-OriginalArrivalTime: 18 Jul 2009 21:22:13.0739 (UTC) FILETIME=[D186B3B0:01CA07ED] X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01CA07ED.D0F723CA Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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." =20 From: Matt Lund [mailto:mlund@control4.com]=20 Sent: Saturday, July 18, 2009 3:20 PM To: Log4NET User Subject: RE: Wrapping Log4Net =20 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. =20 In short, I'd reconsider wrapping it. =20 From: Peter Drier [mailto:peter.drier@gmail.com]=20 Sent: Saturday, July 18, 2009 3:10 PM To: Log4NET User Subject: Re: Wrapping Log4Net =20 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. =20 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 time. =20 -Peter On Sat, Jul 18, 2009 at 4:53 PM, xalex wrote: Hi forum, I would like to use log4net in a large .net development. because i have the requirement to prepare a potential replacement of the log4net framework e.g. against ms-enterprise library or against a newer version of log4net, i would 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 (see below). This wrapper allows me to restrict the users on only the main functions which are really needed and allows me to replace this framework, potentially. Now my question: When the ILog.Debug() Method is called, the output in the logfile is wrong, because the LocationInfo used for this output corresponds 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 the release build, i dont get any output Thanks Alex Wrapper: ------------ 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 =3D new MyLog(log4net.LogManager.GetLogger(type) ); return log; } } public class MyLog :ILog { private log4net.ILog _log; public MyLog(log4net.ILog log) { _log =3D log; } #region ILog Members public bool IsDebugEnabled { get { return _log.IsDebugEnabled; } } public void Debug(object message) { _log.Debug(message); } ... } -- View this message in context: http://www.nabble.com/Wrapping-Log4Net-tp24551728p24551728.html Sent from the Log4net - Users mailing list archive at Nabble.com. =20 ------_=_NextPart_001_01CA07ED.D0F723CA Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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 time.  

-Peter

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 = the
requirement to prepare a potential replacement of the log4net framework = e.g.
against ms-enterprise library or against a newer version of log4net, i = would
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 = (see
below).

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

Now my question: When the ILog.Debug() Method is called, the output in = the
logfile is wrong, because the LocationInfo used for this output = corresponds
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 = the
release build, i dont get any output

Thanks
Alex



Wrapper:
------------
   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 =3D new MyLog(log4net.LogManager.GetLogger(type) );
           return log;
       }
   }

   public class MyLog :ILog
   {
       private log4net.ILog _log;

       public MyLog(log4net.ILog log)
       {
           _log =3D log;
       }

       #region ILog Members

       public bool IsDebugEnabled
       {
           get { return = _log.IsDebugEnabled; }
       }


       public void Debug(object message)
       {
           _log.Debug(message);
       }

  ...
}

--
View this message in context: http://www.nabble.com/Wrapping-Log4Net-tp24551728p24551= 728.html
Sent from the Log4net - Users mailing list archive at = Nabble.com.

 

------_=_NextPart_001_01CA07ED.D0F723CA--