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

Curt Arnold commented on LOG4NET-290:
-------------------------------------

It looks the like original code was very concerned about the cost of boxing and 
unboxing an integer, array creation and a function call on calls when the level 
is higher than debug. If those were not of concern, you could simplify the call 
to 

log.DebugFormat("x: {0}", 123) 

You would not incur any formatting costs unless the logger was at debug or 
lower.

The LogMF and LogSF helper classes in log4j present a vararg like experience 
while avoiding the array creation and boxing costs for the most common calls. A 
call using LogMF would look like

LogMF.debug(log, "x: {0}", 123);

That call should have no array creation or boxing overhead.

Obtaining a formatter was a very expensive operation on Java. LogMF ended up 
having its own implementation of the simplest use patterns for MessageFormatter 
and only delegating to MessageFormat when the pattern was more complex.

It would be very interesting to see a profile of the current log4net ...Format 
method, compared to a lambda approach, compared to the LogMF approach.

> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to