Last active
August 29, 2015 14:01
-
-
Save ChocoSmith/0055a8ed92e57cf0e6a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Web; | |
using NLog; | |
namespace Choco.Shared.Web.App_Start | |
{ | |
public class LogSoapModule : IHttpModule | |
{ | |
public void Init(HttpApplication context) | |
{ | |
context.BeginRequest += this.OnBegin; | |
} | |
private void OnBegin(object sender, EventArgs e) | |
{ | |
var context = ((HttpApplication) sender).Context; | |
var innerLogger = LogManager.GetLogger("incomingRequest"); | |
innerLogger.Info(context.Request.Url); | |
if (!innerLogger.IsTraceEnabled) | |
return; | |
byte[] buffer = new byte[context.Request.InputStream.Length]; | |
context.Request.InputStream.Read(buffer, 0, buffer.Length); | |
context.Request.InputStream.Position = 0; | |
string soapMessage = Encoding.ASCII.GetString(buffer); | |
if (!string.IsNullOrEmpty(soapMessage)) | |
innerLogger.Trace(soapMessage); | |
} | |
public void Dispose() | |
{ | |
// | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.webServer> | |
<modules runAllManagedModulesForAllRequests="true"> | |
<add name="LogSoapModule" type="Choco.Shared.Web.App_Start.LogSoapModule" /> | |
</modules> | |
</system.webServer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment