logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1345626 - /logging/log4net/trunk/src/Layout/Pattern/AspNetRequestPatternConverter.cs
Date Sun, 03 Jun 2012 07:18:47 GMT
Author: bodewig
Date: Sun Jun  3 07:18:47 2012
New Revision: 1345626

URL: http://svn.apache.org/viewvc?rev=1345626&view=rev
Log:
LOG4NET-331 gracefully handle IIS7 integrated mode's behavior when request is not available
(other modes and versions simply return null for the request property)

Modified:
    logging/log4net/trunk/src/Layout/Pattern/AspNetRequestPatternConverter.cs

Modified: logging/log4net/trunk/src/Layout/Pattern/AspNetRequestPatternConverter.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Layout/Pattern/AspNetRequestPatternConverter.cs?rev=1345626&r1=1345625&r2=1345626&view=diff
==============================================================================
--- logging/log4net/trunk/src/Layout/Pattern/AspNetRequestPatternConverter.cs (original)
+++ logging/log4net/trunk/src/Layout/Pattern/AspNetRequestPatternConverter.cs Sun Jun  3 07:18:47
2012
@@ -54,7 +54,17 @@ namespace log4net.Layout.Pattern
 		/// </remarks>
 		protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext
httpContext)
 		{
-			if (httpContext.Request != null)
+		    HttpRequest request = null;
+		    try {
+			request = httpContext.Request;
+		    } catch (HttpException) {
+			// likely a case of running in IIS integrated mode
+			// when inside an Application_Start event.
+			// treat it like a case of the Request
+			// property returning null
+		    }
+
+			if (request != null)
 			{
 				if (Option != null)
 				{



Mime
View raw message