logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George Chung <geo...@glympse.com>
Subject recommendation for AspNetPatternLayoutConverter
Date Fri, 27 Jul 2012 20:42:54 GMT
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. 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/

Mime
View raw message