Return-Path: Delivered-To: apmail-ibatis-dev-archive@www.apache.org Received: (qmail 78663 invoked from network); 30 Jun 2005 05:22:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Jun 2005 05:22:30 -0000 Received: (qmail 81024 invoked by uid 500); 30 Jun 2005 05:22:29 -0000 Delivered-To: apmail-ibatis-dev-archive@ibatis.apache.org Received: (qmail 80992 invoked by uid 500); 30 Jun 2005 05:22:29 -0000 Mailing-List: contact dev-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ibatis.apache.org Delivered-To: mailing list dev@ibatis.apache.org Received: (qmail 80975 invoked by uid 99); 30 Jun 2005 05:22:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jun 2005 22:22:28 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_40_50,HTML_MESSAGE,RCVD_BY_IP X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of ibatis.net@gmail.com designates 64.233.182.201 as permitted sender) Received: from [64.233.182.201] (HELO nproxy.gmail.com) (64.233.182.201) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jun 2005 22:22:31 -0700 Received: by nproxy.gmail.com with SMTP id i2so3803nfe for ; Wed, 29 Jun 2005 22:22:25 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=HWGqUqfSQa4pMvSEzkB0q0wpjLBL3NLh84OLTyB3zYw6ojrPQCOs+yniFFP16Gg6iKU9eqjl6bMia8t5lkk5ewALKbN1XVgQoXOMLhL/2xxyRaPhjtlXr8aleIWjtB7qdtlwzjO3/0FlR1rGjB0m1vHtpzOmKMD9A0AKBr+bVLc= Received: by 10.48.240.7 with SMTP id n7mr3901nfh; Wed, 29 Jun 2005 22:22:25 -0700 (PDT) Received: by 10.48.4.6 with HTTP; Wed, 29 Jun 2005 22:22:25 -0700 (PDT) Message-ID: Date: Thu, 30 Jun 2005 07:22:25 +0200 From: Gilles Bayon Reply-To: Gilles Bayon To: dev@ibatis.apache.org Subject: Re: IBatisNet.Common.Logging In-Reply-To: <20050630045209.47032.qmail@web32211.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4496_8361339.1120108945460" References: <20050630042253.29687.qmail@web32213.mail.mud.yahoo.com> <20050630045209.47032.qmail@web32211.mail.mud.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_4496_8361339.1120108945460 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 6/30/05, Ron Grabowski wrote:=20 >=20 > Will the reference to log4net in IBatisNet.Common be going away at some > point before the next release? Don't think, to do this we must remove Log4NetLogger, Log4NetLoggerFA The built-in logging implementations should probably have checks around > the logging call: >=20 > public void Debug(object message, Exception e) > { > if (_log.IsDebugEnabled) > { > _log.Debug( message, e ); > } > } The *IBatisNet.Common.Logging*=20 is justa wrapper arround logging framework and it's not his responsability= =20 to check if the the level is enabled. =20 I'm not sure how final your code is yet Gilles. I didn't want to go > messing around changing code if you were still double-checking things. >=20 > --- Ron Grabowski wrote: >=20 > > Now that we have our own LogManager, we could borrow NLog's idea of > > GetCurrentClassLogger() to return the logger for the current class > > instead of the usual System.Reflection... way: > > > > // current way > > ILog log =3D > > > LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod > ().DeclaringType > > ); > > > > // less verbose > > ILog log =3D LogManager.GetCurrentClassLogger(); > > -1 not an issue > I haven't looked at NLog's implementation of GetCurrentClassLogger() > > but I would imagine it involves digging through the stack: > > > > StackTrace callStack =3D new StackTrace(); > > StackFrame frame =3D callStack.GetFrame(1); // 2 ??? > > MethodBase method =3D frame.GetMethod(); > > Type declaringType =3D method.DeclaringType; // ??? > > return LogManager.GetLogger(declaringType); > > > > One could argue that doing that is "slower". A counter-argument would > > be that the System.Reflection... call is slow compared to: > > > > ILog log =3D LogManager.GetLogger("IBatisNet.DataAccess.DaoManager"); > > > > Its a really a non-issue since the logger is static and the call only > > happens once. > > > > Could NoOpLogger (and/or all the built-in log implementations) be > > marked as sealed? I can't think of a case where it would be extended. > > +1=20 > I'm in favor of making our ILog match log4net's ILog: > > > > http://tinyurl.com/ch9b7 > > >=20 > http://cvs.apache.org/viewcvs.cgi/logging-log4net/src/ILog.cs?rev=3D1.10&= view=3Dmarkup I haven't seen but +1 (you can do it :-) > The new beta has overloads similiar to the StringBuilder's > > AppendFormat > > method: > > > > DebugFormat(string format, params object[] args) > > > > It makes things slightly cleaner: > > > > _logger.Debug("Open Connection [{0}] to [{1}].", > > _connection.GetHashCode(), // 0 > > _dataSource.Provider.Description)); // 1 > > > > Perhaps the SimpleLogger could have an additional option indicating > > whether it should write to the Console.Out, System.Diagnostic.Trace, > > or > > both: > > +1 Another way will be to replace it with=20 - ConsoleOutLogger=20 - ConsoleErrorLogger - TraceLogger implementation > // Print to the appropriate destination > > System.Console.Error.WriteLine( sb.ToString() ); > > System.Diagnostics.Trace.WriteLine( sb.ToString() ); > > > > I believe NLog and log4net both write to Console.Out rather than > > Console.Error. > > > > If there were support for writing to Trace, one could easily redirect > > the output using a TraceListener in their App.config file: > > > > > > > > > > > type=3D"System.Diagnostics.TextWriterTraceListener" > > initializeData=3D"C:\\IBatisNetLog.txt" /> > > > > > > > > > > I wonder if these two lines are the same. I forgot that C# had a > > PadRight :-) > > > > > sb.Append(string.Format("[{0}]",level.ToString().ToUpper()).PadRight(8)); > > sb.AppendFormat("[{0,-8}],level.ToString().ToUpper()); > > > > - Ron > > >=20 > ------=_Part_4496_8361339.1120108945460 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
On 6/30/05, = Ron Grabowski <rongrabowsk= i@yahoo.com> wrote:
Will the reference to log4net in= IBatisNet.Common be going away at some
point before the next release?
 
Don't think, to do this we must remove Log4NetLogger,= Log4NetLoggerFA

The built-in logging implementat= ions should probably have checks around
the logging call:

public = void Debug(object message, Exception e)
{
if (_log.IsDebugEnabled)
{
  _log.Debug( message, = e );
}
}
The IBatisNet.Co= mmon.Logging  
is justa wrapper arround log= ging framework and it's not his responsability to check if the the level is= enabled.
 

I'm not sure how final your code= is yet Gilles. I didn't want to go
messing around changing code if you = were still double-checking things.

--- Ron Grabowski <ron= grabowski@yahoo.com> wrote:

> Now that we have our own Log= Manager, we could borrow NLog's idea of
> GetCurrentClassLogger() to = return the logger for the current class
> instead of the usual System.Reflection... way:
>
> // = current way
> ILog log =3D
>
LogManager.GetLogger(System.Ref= lection.MethodBase.GetCurrentMethod().DeclaringType
> );
>
> // less verbose
> ILog log =3D LogManager.GetCurrentClassLogger(= );
>
-1 not an issue

> I haven't looked at NLog's = implementation of GetCurrentClassLogger()
> but I would imagine it in= volves digging through the stack:
>
>  StackTrace callStack =3D new StackTrace();
&= gt;  StackFrame frame =3D callStack.GetFrame(1); // 2 ???
>=   MethodBase method =3D frame.GetMethod();
>  Typ= e declaringType =3D method.DeclaringType; // ???
>  return LogManager.GetLogger(declaringType);
>
= > One could argue that doing that is "slower". A counter-argum= ent would
> be that the System.Reflection... call is slow compared to= :
>
>  ILog log =3D LogManager.GetLogger("IBatisNet.DataA= ccess.DaoManager");
>
> Its a really a non-issue since the= logger is static and the call only
> happens once.
>
> C= ould NoOpLogger (and/or all the built-in log implementations) be
> marked as sealed? I can't think of a case where it would be extend= ed.
>
 
+1

> I'm in favor of making our = ILog match log4net's ILog:
>
> http://tinyurl.com/ch9b7
>
http://= cvs.apache.org/viewcvs.cgi/logging-log4net/src/ILog.cs?rev=3D1.10&view= =3Dmarkup
 
I haven't seen but +1 (you can do it :-)

> The new beta has overloads = similiar to the StringBuilder's
> AppendFormat
> method:
>= ;
>  DebugFormat(string format, params object[] args)
>= ;
> It makes things slightly cleaner:
>
>  _log= ger.Debug("Open Connection [{0}] to [{1}].",
>   = _connection.GetHashCode(), // 0
>   _dataSource.Provider.Description)); // 1
>
&g= t; Perhaps the SimpleLogger could have an additional option indicating
&= gt; whether it should write to the Console.Out, System.Diagnostic.Trace,> or
> both:
>
 
+1
Another way will be to replace it with
- ConsoleOutLogger
- ConsoleErrorLogger
- TraceLogger
implementation

>  // Print to the = appropriate destination
>  System.Console.Error.WriteLine( = sb.ToString() );
>  System.Diagnostics.Trace.WriteLine( sb.ToString() );
>= ;
> I believe NLog and log4net both write to Console.Out rather than<= br>> Console.Error.
>
> If there were support for writing to= Trace, one could easily redirect
> the output using a TraceListener in their App.config file:
>=
>  <system.diagnostics>
>   <trac= e autoflush=3D"true">
>    <liste= ners>
>     <add name=3D"textWriterTra= ceListener"
>      type=3D"System.Diagnostics= .TextWriterTraceListener"
>      i= nitializeData=3D"C:\\IBatisNetLog.txt" />
>  &= nbsp; </listeners>
>   </trace>
>&nb= sp; </system.diagnostics>
>
> I wonder if these two lines are the same. I forgot that C#= had a
> PadRight :-)
>
>
sb.Append(string.Format(&quo= t;[{0}]",level.ToString().ToUpper()).PadRight(8));
> sb.AppendFo= rmat ("[{0,-8}],level.ToString().ToUpper());
>
> - Ron
><= br>

------=_Part_4496_8361339.1120108945460--