1
我目前向用戶顯示一個自定義樣式的錯誤消息,我已經構建了以下this post。這工作正常,但我想知道我應該如何在日誌文件中實際記錄這些錯誤。目前我們已經實現了log4net進行日誌記錄。在視圖中記錄異常
這裏是我的模板:
@model System.Web.Mvc.HandleErrorInfo
<div class="span3"></div>
<div class="span5">
<div class="well">
<h3>Oops!</h3>
<div class="alert alert-info alert-block">
<strong>An error has occurred</strong>
<p>
We have logged the incident for you.
Should it continue to occur, please contact support via one of the following options
</p>
<br />
<p class="pull-right"><a href="mailto:[email protected]">[email protected]</a></p>
<address>
<strong>Company Inc.</strong><br>
Address 3<br>
0055 Somewhere, Country<br>
<abbr title="Phone">P:</abbr>
+47 999 99 999
</address>
</div>
<div class="alert alert-error alert-block">
<strong>Exception details (@Model.ControllerName/@Model.ActionName)</strong>
<p>
@Model.Exception.Message
</p>
</div>
</div>
</div>
Web.config文件:
<customErrors mode="On">
<error statusCode="404" redirect="~/Error404/Index" />
</customErrors>
注意,Error404視圖有其自己的控制器,它駐留在其自己的視圖文件夾,而我Error.cshtml視圖不 - 它駐留在共享文件夾中,與我的佈局一起。任何幫助,將不勝感激:)
我有同樣的問題,成功地從剃刀視圖中記錄異常? – GANI