Tag: trace

如何在MVC3中获取trace.axd的自定义错误页面?

我的MVC3应用程序显示403,404和500状态代码的自定义错误页面,但浏览到trace.axd会显示以下YSOD: Server Error in ‘/’ Application. Trace Error Description: Trace.axd is not enabled in the configuration file for this application. Note: Trace is never enabled when Details: To enable trace.axd, please create a tag within the configuration file located in the root directory of the current web application. This tag should then have its “enabled” […]

了解Trace如何在C#中工作

我试图了解跟踪是如何工作的 我创建了一个简单的新Web项目。 这是我可以使用的代码 // Create a trace listener for the event log. EventLogTraceListener myTraceListener = new EventLogTraceListener(“myEventLogSource”); // Add the event log trace listener to the collection. Trace.Listeners.Add(myTraceListener); // Write output to the event log. Trace.WriteLine(“Test output”); 我正在从这个msdn链接中获取帮助 我的web.config中的设置如下 但是,当我运行此代码时,我不知道这个日志记录发生在哪里我检查了事件查看器,在“应用程序和服务日志”下,我期望创建一个名为“myEventLogSource”的新日志但是没有发生。 请任何人解释我这是如何工作的。

启用ODP.Net日志记录

任何人都可以帮我在Windows XP机器上启用ODP.Net日志记录吗? 我用Google搜索并发现以下链接,但它对我不起作用。 http://download.oracle.com/docs/html/E10927_01/featConfig.htm 我在注册表中将“TraceLevel”设置为“63”但它没有帮助 基本上我想通过日志捕获从我的C#代码发生的所有数据库调用。 我希望Oracle有一个像“SQL Profiler”这样的工具。

定义多个未运行的TraceSource

我是TraceSource的新手,所以我正在调查它是如何使用/不能使用的(基本上是优点和缺点)。 我喜欢的是我可以从.NET框架本身获取转储,所以我做了一个小应用程序来测试它并一起使用我自己的自定义源(因为这是我期望它被使用的方式),像这样: class Program { static void Main(string[] args) { SmtpClient smtp = new SmtpClient(); var mm = new MailMessage(); mm.To.Add(“me@my-site.com”); mm.Subject = “Trace Testing”; smtp.Send(mm); var ts = new TraceSource(“MyCustomTracer”); ts.TraceEvent(TraceEventType.Error, 0, “This is an error”); ts.TraceEvent(TraceEventType.Information, 0, “Just debugging now”); } } 我已经在App.config添加了一些监听器,如下所示: 但由于某些原因,当我运行应用程序时,我通过MyCustomTracer记录的2个事件不会进入日志文件,除非我注释掉SmtpClient东西(即 – 只使用我的自定义跟踪器)。 我原以为可以按照我试图使用它们的方式使用多个TraceSource,我只是不确定出了什么问题。

如何在客户端启用WCF跟踪?

我想使用WCF跟踪function。 在这里,我找到了帮助打开服务端的WCF跟踪。 现在,我想在客户端启用WCF跟踪function,以获取我只能使用的WCF服务。

.NET跟踪不能与Diagnostics.TraceSource一起使用,只能使用Diagnostics.Trace

我正在尝试设置.NET跟踪。 我可以通过System.Diagnostics.Trace获得基本的跟踪工作,但由于复杂的原因,我必须通过System.Diagnostics.TraceSource对象激活跟踪(从.NET 2.0开始的新方法)而不是使用System .Diagnostics.Trace。 我已经尝试了一切,但它只是不想使用TraceSource。 我在ASP.NET代码隐藏(aspx.cs)中执行跟踪 以下是一些相关的url: http://msdn.microsoft.com/en-us/library/ty48b824.aspx http://msdn.microsoft.com/en-us/library/64yxa344.aspx http://msdn.microsoft.com/en-us/library/sk36c28t.aspx http://blogs.msdn.com/b/bclteam/archive/2005/03/15/396431.aspx http://msdn.microsoft.com/en-us/library/b0ectfxd%28v=VS.100%29.aspx 目前,根据web.config中的内容,它应该跟踪文件和页面,从这段代码: TraceSource ts = new TraceSource(“mysource”, SourceLevels.All); Trace.Write(“Trace (old way)”); // this one works ts.TraceInformation(“Trace (new way)”); // this one doesn’t work ts.Flush(); ts.Close(); 这是相关的web.config部分:

跟踪日志位置,查看位置

你在哪里看到Trace.Write(“”); 在开发MVC或WCF应用程序时记录日志? 什么是正确的地方?

System.Net(HttpWebRequest)跟踪而不使用文件或app.config?

我想在我的应用程序中捕获某些但不是全部的HttpWebRequest流量以进行调试。 它是由IIS托管的Web服务。 我已阅读如何:配置网络跟踪 。 这很好用,但我不希望将跟踪指向文件,因为文件系统可能存在权限问题,数据敏感性等。我想直接捕获内存中的某些东西,我随后可以检查或加密和电子邮件。 最好不要对app.config文件进行任何更改。 我尝试了以下内容,但显然我错过了将TextWriterTraceListener绑定到System.Net的步骤。 如何将System.Net流量捕获到我的StringWriter中? StringWriter sw = new StringWriter(); TextWriterTraceListener myListener = new TextWriterTraceListener(sw); Trace.Listeners.Add(myListener); HttpWebRequest req = (HttpWebRequest) WebRequest.Create(“http://www.microsoft.com”); HttpWebResponse resp = (HttpWebResponse) req.GetResponse(); Stream s = resp.GetResponseStream(); byte[] buf = new byte[4096]; while (s.Read(buf, 0, buf.Length) > 0) ; s.Close(); myListener.Flush(); sw.Flush(); 编辑:具体来说,我想在运行时做相同的操作,除了我不想输出到network.log,我希望它转到我为此目的设置的字符串缓冲区。