Daniel Ovaska
Nov 30, 2016
  2527
(5 votes)

Glimpse + Episerver = true

Glimpse is a great tool for checking what is going in under the hood in your application. Unlike the Chrome F12 tools, Glimpse can actually tell you what is going on on the server side, like

  • What is the stored in session?
  • How long was the execution time on the server?
  • What log messages did this request produce?
  • Who is the current user on server?
  • What MVC views were rendered?

It's really extendible and you can add new tabs and statistics to it. Unfortunately it doesn't work with Episerver out of the box. But with a few configuration changes it's no problem.

So how does it look on the Alloy site? In minimized mode it looks like:

Notice that you get information about the actual execution time on server? Sweet!

Let's check out the expanded mode if you click it:

Here I added a new tab for Episerver that includes the current page type and it's properties. I'll add more stuff to it in next version. The Session tab will give you information about what is stored for the current user. The trace tab is worth mentioning as well. With just a few lines of configuration to log4net you can get all your log messages from log4net here. 

Add a new appender in Episerverlog.config

<appender name="AspNetTraceAppender" type="log4net.Appender.AspNetTraceAppender" >
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
</appender>

Use it...I'll switch in on for the root element to get everything (remember to switch it off when you are done...)

<root>
  <level value="All" />
  <appender-ref ref="AspNetTraceAppender" />
</root>

...and turn on trace in web.config

<trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false"/>

Done! Let's check it out!

Now you also get all log4net messages in the trace tab for every request! How sweet is that?

For security, I disabled Glimpse to only allow it to run if the user has one of the groups "CMSAdmins", "WebAdmins" or "GlimpseUser". That should take care of most security aspects. If you need additional security like only allowing it to run if you are browsing from the server itselt, that easy as well. 

Nuget package is available on Episerver feed for Episerver 10+ if you want to try it out. Feel free to ctrl-c any code you like on my github if you want to do it yourself. 

Happy Glimpsing!

Nov 30, 2016

Comments

valdis
valdis Nov 30, 2016 07:55 PM

Awesome! Btw, FeatureSwitch also has tab there ;)

Dec 2, 2016 02:29 PM

Thx! I got to check out Feature switch Valdis :)

It's on my todo list.

Branching might be funny...merging isn't.

Enter FeatureSwitch :)

Deepa Puranik
Deepa Puranik Feb 1, 2021 08:14 AM

Hi,

How to add the EPiServer tab to the glimpse ?

Can you please help me how to configure tabs for glimpse.

Daniel Ovaska
Daniel Ovaska Feb 9, 2021 01:18 PM

Added support for Episerver v11 to Episerver nuget feed. Will be up when approved.

Please login to comment.
Latest blogs
Integrating Optimizely DAM with Your Website

This article is the second in a series about integrating Optimizely DAM with websites. It discusses how to install the necessary package and code t...

Andrew Markham | Sep 28, 2024 | Syndicated blog

Opticon 2024 - highlights

I went to Opticon in Stockholm and here are my brief highlights based on the demos, presentations and roadmaps  Optimizely CMS SaaS will start to...

Daniel Ovaska | Sep 27, 2024

Required fields support in Optimizely Graph

It's been possible to have "required" properties (value must be entered) in the CMS for a long time. The required metadata haven't been reflected i...

Jonas Bergqvist | Sep 25, 2024

How to write a bespoke notification management system

Websites can be the perfect vehicle for notifying customers of important information quickly, whether it’s the latest offer, an operational message...

Nicole Drath | Sep 25, 2024