[ 
https://issues.apache.org/jira/browse/LOG4NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13628786#comment-13628786
 ] 

Dominik Psenner commented on LOG4NET-290:
-----------------------------------------

Hi Pavel, thanks for bumping this issue. I spent some spare minute to think 
about this idea and am inclined to walk along the path of this idea, but 
disagree on the finer details. Currently everyone can create an static 
extension class that implements this functionality as easy as that:

public static class ILogExtensions
{
                public static void FatalExt(this ILog logger, object message)
                {
                        if (!logger.IsFatalEnabled)
                                return;

                        logger.Fatal(message);
                }
}

and then call that extension as:

log.FatalExt(message);

which semantically matches the statements:

if(log.IsFatalEnabled)
        logger.Fatal(message);

but does not suffer from the flaws of lambda expressions (lambda expressions 
are hard to understand, odd stacktraces, programming with JIT while debugging, 
..). We could of course add those extensions to log4net so everyone has them in 
future versions. Comments?
                
> Add Lambda-based ILog-Extensions (embedded log.IsEnabled)
> ---------------------------------------------------------
>
>                 Key: LOG4NET-290
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-290
>             Project: Log4net
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 1.2.10
>            Reporter: Lars Corneliussen
>             Fix For: 3.5
>
>
> This statement:
>     if (log.IsDebugEnabled) log.DebugFormat("x: {0}", 123)
> Could be nicely shortened to:
>     log.Debug( m=>m("value= {0}", obj.Value) );
> I'm already apache committer (NPanday Incubator Project) and would be happy 
> to help with this interface. The simplest thing would be to offer it as 
> static Extension-Methods to ILog.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to