[ https://issues.apache.org/jira/browse/LOG4NET-217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917791#comment-13917791 ]
Dominik Psenner commented on LOG4NET-217: ----------------------------------------- The log4net approach to this problem is to reduce the number invocations in those cases and create log events only when necessary. However, it is not possible to invoke the methods in another thread without loosing the original thread's context. The implications are a thousandfold whereas logging event appenders do already implement asynch features. If constructing a log event really takes a large amount of time, it may be wise to do some performance improvements because it behaves to the application like an anchor does on a ship. > Delayed log > ----------- > > Key: LOG4NET-217 > URL: https://issues.apache.org/jira/browse/LOG4NET-217 > Project: Log4net > Issue Type: Improvement > Components: Core > Affects Versions: 1.2.10 > Reporter: Fabio Maulo > Assignee: Dominik Psenner > Priority: Minor > Fix For: 1.2.12 > > > would be useful an override like this > ILog.Debug(Func<string> messageDelegate); > callable as > log..Debug(()=> MyTimeExpensiveMethod); > This is to prevent boiled code as > if(log.IsDebugEnable) > { > log..Debug(MyTimeExpensiveMethod()); > } > Log4Net can call the messageDelegate only when really needed. > If you want stay in NET2.0 you can create a specific delegate > public delegate string MessageDelegate; > Btw, IMO, the new version should target directly .NET3.5. -- This message was sent by Atlassian JIRA (v6.2#6252)