Catch exception and log it (C#) : Eventlog « Development « ASP.NET Tutorial






<%@ Page %>
<script language="C#" runat="server">
  private void Page_Load(object sender, System.EventArgs e)
  {
    int a=0;
    System.Diagnostics.EventLog myEventLog;
    
    try {
      a=1/a;
    } catch (Exception ex) {  
      myEventLog=new System.Diagnostics.EventLog();
      myEventLog.Log="Application";
      myEventLog.Source="asp";
      myEventLog.WriteEntry(ex.ToString());
    }
  }
</script>

<html>
  <body>
    <form id="form1" method="post" runat="server">
    </form>
  </body>
</html>








9.17.Eventlog
9.17.1.Write the information to the event log. Register the event source if needed. (C#)
9.17.2.Write the exception information to the event log (C#)
9.17.3.List all event log entries (C#)
9.17.4.Catch exception and log it (C#)
9.17.5.Catch exception and log it (VB)