我看过他们的帮助页面,似乎我可以注册一个将信息输出到“标准ASP.NET调试窗口”的调试记录器。我的问题是我不知道这是什么意思,如果它指的是Visual Studio中的调试输出窗口(在那里你可以看到构建输出,调试输出等等),我看不到任何UrlRewriter调试输出。
规则是有效的(大部分),我只是想获得更多的调试输出来解决问题。
我将寄存器调用添加到重写器部分,如下所示:
<rewriter>
<register logger="Intelligencia.UrlRewriter.Logging.DebugLogger, Intelligencia.UrlRewriter" />
....
</rewriter>我在Vista上的IIS本地托管这个网站,为了调试它,我将调试器附加到w3wp进程。
Web.config表中的其他选定部件“
<compilation debug="true">
<assemblies>
...
</assemblies>
</compilation>
<trace enabled="true"/>我应该在哪里看到UrlRewriter.NET的调试输出?如果它在Visual Studio的调试输出窗口中,你知道为什么我没有在那里看到它吗?
发布于 2010-03-14 16:37:00
尝试运行用于从Intelligencia.UrlRewriter读取消息的DebugView
从这里获取http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
我看到了源代码,我相信这是有效的,但如果不起作用,为什么不获得源代码,并编译它与您的项目,并只是在现场调试它?
发布于 2010-03-30 20:03:07
我想要调试,因为我感觉我的重写规则不起作用。
过了一段时间,我想我必须修改我的web.config,并在'system.web','httpModules‘部分添加以下行:
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>发布于 2011-06-16 19:53:21
对于任何想要将事件消息记录到文件中并在调试输出窗口中查看它们的人,这里有我创建的一段代码。
请仅在开发环境中使用此代码,此代码未经过优化。
用法:
In your asp.net application, add a reference to this library (MyPresentationLayer.Web). Add the following element to 'rewriter' node:<register logger="IntelligenciaExt.Web.Logging.UrlRewriterIntelligencia.FileLogger, IntelligenciaExt.Web"/>
By default the log file can be found outside your 'www' folder, in the subfolder 'intelligenciaLog'. using System;
using SysDiag = System.Diagnostics;
using System.IO;
using Intelligencia.UrlRewriter.Logging;
namespace MyPresentationLayer.Web.Logging.UrlRewriterIntelligencia
{
/// <summary>
/// Custom logger for Intelligencia UrlRewriter.net that logs messages
/// to a plain text file (../intelligenciaLog/log.txt).
/// </summary>
public class FileLogger : IRewriteLogger
{
private const string _logFolderName = "../intelligenciaLog";
private const string _logFileName = "log.txt";
private const string _appName = "UrlRewriterIntelligencia.FileLogger";
public FileLogger()
{
LogToFile(Level.Info, "Created new instance of class 'FileLogger'");
}
public void Debug(object message)
{
LogToFile(Level.Debug, (string)message);
}
public void Error(object message, Exception exception)
{
string errorMessage = String.Format("{0} ({1})", message, exception);
LogToFile(Level.Error, errorMessage);
}
public void Error(object message)
{
LogToFile(Level.Error, (string)message);
}
public void Fatal(object message, Exception exception)
{
string fatalMessage = String.Format("{0} ({1})", message, exception);
LogToFile(Level.Fatal, fatalMessage);
}
public void Info(object message)
{
LogToFile(Level.Info, (string)message);
}
public void Warn(object message)
{
LogToFile(Level.Warn, (string)message);
}
private static void LogToFile(Level level, string message)
{
string outputMessage = String.Format("[{0} {1} {2}] {3}", DateTime.Now.ToString("yyyyMMdd HH:mm:ss"),
_appName.PadRight(50, ' '), level.ToString().PadRight(5, ' '),
message);
SysDiag.Debug.WriteLine(outputMessage);
try
{
string pathToLogFolder =Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _logFolderName);
if (!Directory.Exists(pathToLogFolder))
{
Directory.CreateDirectory(pathToLogFolder);
}
string fullPathToLogFile = Path.Combine(pathToLogFolder, _logFileName);
using (StreamWriter w = File.AppendText(fullPathToLogFile))
{
w.WriteLine(outputMessage);
// Update the underlying file.
w.Flush(); // Close the writer and underlying file.
w.Close();
}
}
catch (Exception) { }
}
internal enum Level
{
Warn,
Fatal,
Info,
Error,
Debug
}
}
}https://stackoverflow.com/questions/2434292
复制相似问题