現在、この投稿に従って作成したカスタム スタイルのエラー メッセージをユーザーに表示しています。これは問題なく動作しますが、これらのエラーを実際にログ ファイルに記録する方法を知りたいと思っています。現在、ロギング用に 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:support@company.com">support@company.com</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 ビューにはありません。レイアウトと共に共有フォルダーに存在します。どんな助けでも大歓迎です:)