logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominik Psenner <dpsen...@gmail.com>
Subject Re: recommendation for AspNetPatternLayoutConverter
Date Sun, 29 Jul 2012 21:13:31 GMT
On 07/27/2012 10:42 PM, George Chung wrote:
> It currently defines this abstract method:
> 
> protected abstract
> void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
> 
> I would recommend changing it to:
> 
> protected abstract void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext*Base*
httpContext)
> 
> Effectively, HttpContext.Current is not very useful anymore in more
> recent versions of ASP.NET <http://ASP.NET>. As they are promoting an
> asynchronous programming model where operations complete on completion
> threads. And they also encourage the use of the ParallelTaskLibrary for
> queuing work items. The bulk of your operations are going to execute on
> these threads, and on these threads, HttpContext.Current is null.
> 
> HttpContextBase is what's being used now and it's easy to convert
> HttpContext.Current to an HttpContextBase like this:
> 
> new HttpContextWrapper(HttpContext.Current)
> 
> Here's some more info on the matter.
> 
> http://www.splinter.com.au/httpcontext-vs-httpcontextbase-vs-httpcontext/

I did not change the signature and test the impact on compatibility to
previous versions of log4net, but I would assume that since HttpContext
is not an implementation of HttpContextBase it will not work out of the
box, would it?

And on top of that, HttpContextBase exists only for .NET 3.5/4.0, which
breaks log4net for .NET 1.0/2.0/3.0 unless we juggle around with build
conditionals.

Maybe a "reimplemtation" of the AspNetPatternLayoutConverter would suit
the new usecase better?
-- 
Dominik Psenner
## OpenPGP Key Signature #################################
# Key ID: B469318C                                       #
# Fingerprint: 558641995F7EC2D251354C3A49C7E3D1B469318C  #
##########################################################


Mime
View raw message