On 6/30/05, Ron Grabowski <[EMAIL PROTECTED]> 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 implementations should probably have checks around
the logging call:
public void Debug(object message, Exception e)
{
if (_log.IsDebugEnabled)
{
_log.Debug( message, e );
}
}
The IBatisNet.Common.Logging
is justa wrapper arround logging framework and it's not his responsability to check if the the level is enabled.
is justa wrapper arround logging 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 <[EMAIL PROTECTED]> wrote:
> 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 =
>
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType
> );
>
> // less verbose
> ILog log = 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 = new StackTrace();
> StackFrame frame = callStack.GetFrame(1); // 2 ???
> MethodBase method = frame.GetMethod();
> Type declaringType = 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 = 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
> 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=1.10&view=markup
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
- 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
> 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>
> <trace autoflush="true">
> <listeners>
> <add name="textWriterTraceListener"
> type="System.Diagnostics.TextWriterTraceListener"
> initializeData="C:\\IBatisNetLog.txt" />
> </listeners>
> </trace>
> </system.diagnostics>
>
> 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
>
