私はIISロガーを作成に関する質問をしてきましたが、それでも問題のカップルを持っています:のIHttpModule問題
- オリジナルメッセージが
- 応答メッセージが
をキャプチャされませんが失われますこれらの2つを整理することは可能なのでしょうか?
IHTTPハンドラ:
using System.Web;
using System.IO;
namespace MyLogger
{
public class MyHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.Write("The page request is " + context.Request.RawUrl.ToString());
StreamWriter sw = new StreamWriter(@"C:\requestLog.txt", true);
sw.WriteLine("Page requested at " + DateTime.Now.ToString() + context.Request.RawUrl);
sw.Close();
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
のIHttpModule:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;
namespace MyLogger
{
public class MyModule : IHttpModule
{
public InterceptorModule()
{ }
public void Init(HttpApplication objApplication)
{
// Register event handler of the pipe line
objApplication.BeginRequest += new EventHandler(this.ContextBeginRequest);
objApplication.EndRequest += new EventHandler(this.ContextEndRequest);
}
public void Dispose()
{
}
public void ContextEndRequest(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(@"C:\requestLog.txt", true);
sw.WriteLine("End Request called at " + DateTime.Now.ToString()); sw.Close();
}
public void ContextBeginRequest(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(@"C:\requestLog.txt", true);
sw.WriteLine("Begin request called at " + DateTime.Now.ToString()); sw.Close();
}
}
}
私の前の記事:事前にIIS API Monitor in a web application ありがとう!
多量のマルチスレッド環境で単一の物理ファイルを使用する*この方法*? –
将来の読者があなたの経験から学ぶことができるように、あなたの他の質問に答えを記入してください。 –
私は単純にするためにそこに置いています。私の質問はマルチスレッドに関連していないので、私はそれを断念しました。いずれにせよ、私は答えを有用とマークしましたが、何らかの理由でそれがページに反映されませんでした。そして私は、将来の参考のためにコメント欄に私の発見を残しました。 – Raytrace