2

i have just taken over an app that has a lot of code like below where exceptions are just caught and Console.Write(xxx) is there.

I would like to change this so i have a simple log to review everything there is a Console.write() now.

What is the simplest way for getting this setup in asp.net mvc to have a file to view on the IIS server.

try
{
    SmtpClient c = new SmtpClient("mail.xxx.org");
    c.Send(msg);
}
catch (Exception ex)
{
    Console.Write(ex.Message.ToString());
}
Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
leora
  • 188,729
  • 360
  • 878
  • 1,366
  • There are other similar questions re: ASP.NET MVC. Please see... http://stackoverflow.com/questions/1032373/asp-net-mvc-exception-logging-combined-with-error-handling – Eric Schoonover Aug 06 '09 at 05:32
  • 1
    Also, [this blog](http://blog.dantup.me.uk/2009/04/aspnet-mvc-handleerror-attribute-custom.html) has a good explanation of how to log errors caught by the [HandleError] attribute. – Joseph Yaduvanshi Aug 06 '09 at 05:28

1 Answers1

5

You might want to try the ELMAH library.

Check the project site for some examples.

Scott Hanselman has also written a blog post or two about it.

Richard Banks
  • 12,456
  • 3
  • 46
  • 62