Return-Path: X-Original-To: apmail-logging-log4net-dev-archive@www.apache.org Delivered-To: apmail-logging-log4net-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B016F10AD7 for ; Thu, 17 Oct 2013 11:23:50 +0000 (UTC) Received: (qmail 72698 invoked by uid 500); 17 Oct 2013 11:23:48 -0000 Delivered-To: apmail-logging-log4net-dev-archive@logging.apache.org Received: (qmail 71832 invoked by uid 500); 17 Oct 2013 11:23:46 -0000 Mailing-List: contact log4net-dev-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET Dev" List-Id: Delivered-To: mailing list log4net-dev@logging.apache.org Received: (qmail 71786 invoked by uid 99); 17 Oct 2013 11:23:44 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Oct 2013 11:23:44 +0000 Date: Thu, 17 Oct 2013 11:23:44 +0000 (UTC) From: "Dominik Psenner (JIRA)" To: log4net-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LOG4NET-290) Add Lambda-based ILog-Extensions (embedded log.IsEnabled) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13797800#comment-13797800 ] Dominik Psenner commented on LOG4NET-290: ----------------------------------------- {quote} I expect that usage of this method will look like this: ??logger.DebugExt(() => string.Format("Total value is {0}", CalculateTotalValue()); After that it's much harder to extract actual arguments of template. I understand that it is just my opinion and my case, but it was so good that log4net keeps these things (template and args) separated and I was impressed about it. {quote} As I see it, this signature is there for another purpose, namely to create objects that can be passed into custom object renderers such as: {quote} logger.DebugExt(() => new MyCustomLogObjectBasedOn(otherObjectFoo, otherObjectBar)) {quote} without requiring to write: {quote} if(logger.IsDebugEnabled) { logger.Debug(new MyCustomLogObjectBasedOn(otherObjectFoo, otherObjectBar)) } {quote} but still getting the performance benefits of lazy object instantiation. whereas this: {quote}logger.DebugExt(() => string.Format("Total value is {0}", CalculateTotalValue());{quote} will be written as: {quote}logger.DebugFormat("Total value is {0}", CalculateTotalValue()){quote} or: {quote}logger.DebugFormatExt("Total value is {0}", CalculateTotalValue()){quote} > 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 (v6.1#6144)