本文整理汇总了C#中Logger.LogCritical方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.LogCritical方法的具体用法?C# Logger.LogCritical怎么用?C# Logger.LogCritical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.LogCritical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Session_Start
protected void Session_Start(object sender, EventArgs e)
{
bool isDBReady;
try { isDBReady = (bool)Application["IsDBReady"]; }
catch { isDBReady = false; }
if (isDBReady)
{
//Attempt to retrieve BrowserGUID from cookies
System.Guid myBrowserGuid = System.Guid.Empty;
if (Request.Cookies.Count > 0)
{
//attempt to read our browser guid / device id
try
{ myBrowserGuid = new System.Guid(Request.Cookies[Common.Constants.BROWSER_GUID_KEY].Value.ToString()); }
catch { myBrowserGuid = System.Guid.Empty; }
}
//get locator
DBLocator myDBLocator = (DBLocator)Application["myDBLocator"];
//create session object by injecting locator into session
WebSiteSession mySession = new WebSiteSession(myDBLocator);
//start it
mySession.Start(
Session.SessionID,
myBrowserGuid,
Request.ServerVariables.AllKeys.Contains("HTTP_X_FORWARDED_FOR") ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.UserHostAddress,
Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null,
Request.RawUrl);
//required by base page
Session.Add("mySession", mySession);
}
else
using (Logger myLogger = new Logger())
myLogger.LogCritical("Unable to start session, IsDBReady is false", LogCategory.Database);
}