logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walden Leverich (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled)
Date Wed, 16 Oct 2013 15:29:42 GMT

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

Walden Leverich commented on LOG4NET-290:

Dmitry, I get where you're coming from with the "dummy checks" but it's not always a waste
of time to do the check ahead of time.

Gathering the information to pass into DebugFormat (or any of the other logging methods) can
itself be expensive; you may be calculating results, doing DB I/O, calling services, etc.
And to go though the time to gather all the information just to have DebugFormat short circuit
return because logging is disabled is a complete waste of time. You'd be much better off checking
IsDebugEnabled and then not bothering with the collection if you're not going to use it anyway.

Like everything else, it's a balancing act. Some of our logging statements are wrapped in
the if(), others are just naked calls and we let log4net worry about it.

> 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
>            Assignee: Dominik Psenner
>             Fix For: 1.2.12
>         Attachments: LOG4NET-290-doc.patch, LOG4NET-290.patch
> 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 was sent by Atlassian JIRA

View raw message