diff options
Diffstat (limited to 'samples/RelyingPartyPortal/Global.asax.cs')
-rw-r--r-- | samples/RelyingPartyPortal/Global.asax.cs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/samples/RelyingPartyPortal/Global.asax.cs b/samples/RelyingPartyPortal/Global.asax.cs index 56636a5..eb61da9 100644 --- a/samples/RelyingPartyPortal/Global.asax.cs +++ b/samples/RelyingPartyPortal/Global.asax.cs @@ -1,14 +1,24 @@ using System;
using System.Collections.Specialized;
-using System.Diagnostics;
using System.IO;
+using System.Text;
using System.Web;
namespace ConsumerPortal {
public class Global : System.Web.HttpApplication {
- public Global() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
+ internal static StringBuilder LogMessages = new StringBuilder();
+
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global));
+
+ protected void Application_Start(object sender, EventArgs e) {
+ log4net.Config.XmlConfigurator.Configure();
+ Logger.Info("Sample starting...");
+ }
+
+ protected void Application_End(object sender, EventArgs e) {
+ Logger.Info("Sample shutting down...");
+ // this would be automatic, but in partial trust scenarios it is not.
+ log4net.LogManager.Shutdown();
}
string stripQueryString(Uri uri) {
@@ -19,22 +29,22 @@ namespace ConsumerPortal { protected void Application_BeginRequest(Object sender, EventArgs e) {
// System.Diagnostics.Debugger.Launch();
- Trace.TraceInformation("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
+ Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
if (Request.QueryString.Count > 0)
- Trace.TraceInformation("Querystring follows: \n{0}", ToString(Request.QueryString));
+ Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString));
if (Request.Form.Count > 0)
- Trace.TraceInformation("Posted form follows: \n{0}", ToString(Request.Form));
+ Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form));
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
- Trace.TraceInformation("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
+ Logger.DebugFormat("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
}
protected void Application_EndRequest(Object sender, EventArgs e) {
}
protected void Application_Error(Object sender, EventArgs e) {
- Trace.TraceError("An unhandled exception was raised. Details follow: {0}",
+ Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}",
HttpContext.Current.Server.GetLastError());
}
|