Jeg har lige fundet ud af at med følgende kode, så skriver den noget i min eventlog:
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System.Web.Mail"%>
<script language="C#" runat="server">
void Application_Error(object sender, EventArgs e)
{
String Message = "\n\nURL:\n
http://localhost/" + Request.Path
+ "\n\nMESSAGE:\n " + Server.GetLastError().Message
+ "\n\nSTACK TRACE:\n" + Server.GetLastError().StackTrace;
// Create Event Log if it does not exist
String LogName = "Application";
if (!EventLog.SourceExists(LogName)) {
EventLog.CreateEventSource(LogName, LogName);
}
// Insert into Event Log
EventLog Log = new EventLog();
Log.Source = LogName;
Log.WriteEntry(Message, EventLogEntryType.Error);
}
</script>
Det der står i eventlog på serveren:
The description for Event ID ( 0 ) in Source ( Application ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event:
URL:
http://localhost//test.aspxMESSAGE:
Exception of type System.Web.HttpUnhandledException was thrown.
STACK TRACE:
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously).