[ https://issues.apache.org/jira/browse/LOG4NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13627644#comment-13627644 ]
Pavel Nedoma commented on LOG4NET-290: -------------------------------------- Since I wasn't able to find any conclusion on this topic I would like "reopen" this issue. I'm using log4net in many oh my projects and quite a few of them have the need to write to log objects, whose ToString is not very cheap. To avoid unnecessary calls for configurations that have logging disabled I use lazy evaluation of ToString that depends on the fact whether the related log level is enabled or not. Instead of using if-logenabled-blocks everywhere where is such object logged I prefer more elegant way with a lambda function (e.g. Log.Debug(()=>hugeInstance.ToString());) So far I have a class with extension methods to have logging methods with a delegate in parameters, But I think that this feature could be useful for many log4net users and therefore ILog could be extended to support such signatures. Here is a draft (no doc comments and I think that it could be nice to also have the (delegate, exception) overload) of my solution https://gist.github.com/anonymous/783045423b1c26011ac3 > 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