【问题标题】:Why Trace.WriteLine() doesn't work from the ASP.NET MVC controller为什么 Trace.WriteLine() 在 ASP.NET MVC 控制器中不起作用
【发布时间】:2014-03-18 15:05:56
【问题描述】:

我刚刚创建了小型 Windows Azure 应用程序(它只是一个 WebRole),我正在 Windows Azure Compute Emulator 中对其进行测试(在 VisualStudio 的调试模式下运行)。

但应用程序日志仍然对我不起作用。问题只是我能够从 WebRole.Run() 方法记录消息——我可以看到“foo bar”字符串在调用Run() meth(Web 角色启动)时,在模拟器控制台中。

但是当我尝试从 ASP.NET MVC 控制器操作方法登录时没有发生任何事情(即模拟器控制台中没有日志条目,尽管我的 HTTP 请求调用了控制器操作方法并且效果很好)。

WebRole 类中:

public override void Run()
{
    Trace.WriteLine("foo bar", "Information");
    base.Run();
}

在 ASP.NET MVC 控制器中:

public ActionResult Redirect()
{
    Trace.WriteLine("redirecting ...", "Information");
    // ...
    return RedirectPermanent(url);
}

可能是什么问题?为什么Trace.WriteLine() 不适用于控制器?我有 ASP.NET Web API 控制器以及经典的 ASP.NET MVC 控制器,都是一样的。

或者我完全错了,应该以其他方式执行应用程序日志记录?

【问题讨论】:

    标签: logging azure azure-web-roles


    【解决方案1】:

    【讨论】:

    • 是的,也许是同一个问题。它对我帮助很大,但仍然登录模拟器对我来说似乎有点棘手......仍然无法正常工作。无论如何,谢谢你! +1
    猜你喜欢
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    相关资源
    最近更新 更多