Diagnostic Levels

Diagnostic Levels

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Items.Item
  • Sitecore.Diagnostics.Log
  • Sitecore.Diagnostics.LogNotificationLevel
  • Sitecore.Diagnostics.Statistics
  • Sitecore.Sites.SiteContext
  • System.Enum

Diagnostic Levels C# Web Control Code

Sitecore.Sites.SiteContext site = Sitecore.Context.Site;
Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (site == null || item == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Site", site.Name);
output.RenderEndTag(); //P

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Diagnostic Log Levels");
output.RenderEndTag(); //P
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Ol);
foreach (string logLevel in System.Enum.GetNames(typeof(Sitecore.Diagnostics.LogNotificationLevel)))
{
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Li);
    output.Write("{0}", "<b>" + logLevel + "</b>");
    output.RenderEndTag();
}
output.RenderEndTag(); //Ol
output.Write("<hr />");

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Diagnostic Statistics");
output.RenderEndTag(); //P

output.Write("{0}&#63;&#160;{1}", "Log Enabled", "<b>" + Sitecore.Diagnostics.Log.Enabled.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Request Count", "<b>" + Sitecore.Diagnostics.Statistics.RequestCount.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Request Seconds", "<b>" + Sitecore.Diagnostics.Statistics.RequestTime.TotalSeconds.ToString() + "</b>");
output.RenderEndTag(); //Div


Diagnostic Levels C# Web Control Output

Diagnostic Log Levels

  1. Debug
  2. Info
  3. Warning
  4. Error
  5. Fatal
  6. None

 Diagnostic Statistics

 

Diagnostic StatisticsLog Enabled? True
Request Count: 1122
Request Seconds: 87.725909


Notes

  • You may need to refresh this page several times to display some diagnostic statistics