c# - Log exceptions in view -


i display custom-styled error message users, i've built following this post. works fine, i'm wondering how should log these errors in log-file. we've implemented log4net logging.

here's template:

@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>                 have logged incident you.             should continue occur, please contact support via 1 of 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> 

note error404 view has own controller , resides in own view-folder, whereas error.cshtml view not - resides in shared folder, layouts. appreciated :)

take @ elmah.

i continue logging log4net. there log4net appenders log file or database. issue here log it, have know happened.

if add elmah project capture unhandled exceptions , log file/db/email/whatever configure.

this project had nuget packages easy integration. can't enough it, use in every web project write.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -