You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Lars Corneliussen (JIRA)" <ji...@apache.org> on 2011/04/05 09:00:05 UTC

[jira] [Created] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)

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: 1.2.11


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

Could be nicely shortened to:
{code}
  log.Debug( m=>m("value= {0}", obj.Value) );
{code}

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

RE: [jira] [Updated] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)

Posted by Dominik Psenner <dp...@gmail.com>.
Did you compare runtime performance of the 'if syntax' versus the 'method
invoke syntax'?

> -----Original Message-----
> From: Lars Corneliussen (JIRA) [mailto:jira@apache.org]
> Sent: Tuesday, April 05, 2011 9:00 AM
> To: log4net-dev@logging.apache.org
> Subject: [jira] [Updated] (LOG4NET-290) Add Lambda-based ILog-Extensions
> (embedded log.IsEnabled)
> 
> 
>      [ https://issues.apache.org/jira/browse/LOG4NET-
> 290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
> 
> Lars Corneliussen updated LOG4NET-290:
> --------------------------------------
> 
>     Description:
> 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.
> 
>   was:
> {code}
> if (log.IsDebugEnabled) log.DebugFormat("x: {0}", 123)
> {code}
> 
> Could be nicely shortened to:
> {code}
>   log.Debug( m=>m("value= {0}", obj.Value) );
> {code}
> 
> 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.
> 
> 
> > 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: 1.2.11
> >
> >
> > 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


[jira] [Updated] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)

Posted by "Lars Corneliussen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars Corneliussen updated LOG4NET-290:
--------------------------------------

    Description: 
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.

  was:
{code}
if (log.IsDebugEnabled) log.DebugFormat("x: {0}", 123)
{code}

Could be nicely shortened to:
{code}
  log.Debug( m=>m("value= {0}", obj.Value) );
{code}

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.


> 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: 1.2.11
>
>
> 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

[jira] [Commented] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)

Posted by "Curt Arnold (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13094288#comment-13094288 ] 

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

The JavaDoc for LogMF is http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/LogMF.html. The source is http://svn.apache.org/repos/asf/logging/log4j/trunk/src/main/java/org/apache/log4j/LogMF.java


> 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

        

[jira] [Updated] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)

Posted by "Stefan Bodewig (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig updated LOG4NET-290:
-----------------------------------

    Fix Version/s:     (was: 1.2.11)
                   3.5

Lars, by all means, welcome!  Please join the dev list.

Note that 3.5 is no real version and that we may very well decide to do things differently in the future.

As long as we are trying to support so many different and old frameworks I'm reluctant to add code that would only work with 3.0 and beyond.  1.2.11 is supposed to be released soon and be backwards compatible, that's why I changed the target.



> 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

        

[jira] [Commented] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)

Posted by "Curt Arnold (JIRA)" <ji...@apache.org>.
    [ 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