Hooking into Sitecore’s Logging

Sitecore uses Log4Net for it’s logging framework, so it comes with a whole slew of different ‘appenders’, suitable for logging to various repositories. That’s nice, but what if there’s a target you want to use that doesn’t exist?

Well, you can override the SitecoreLogFileAppender and write your own output:

What else could you do with this? Well, writing to App Insights seems like a good bet.

Hooking into Sitecore’s Logging

Minifying JS – Skip removing line numbers?

I’m a big fan of App Insights, and I’m loving it’s increasing integration with Visual Studio. To me, it’s just great.

However, I did find myself laughing a bit at this. App Insights was recording JavaScript errors from a (third party’s) .JS file.

appinsights

This is showing an error on Line 93. The thing is, the file has been minified – and all the code in the file is on line 93.

Hmm. All this would save is a couple of hundred bytes over the wire. I’m just not sure it’s worth it for most of the projects I work on. I think having the new-lines still in (albeit otherwise minified).

To be honest, we’d save more space by stripping out the 92 lines of Licensing information above the code. I’m not sure that that shouldn’t reside in a text file, and just have a comment referencing the licence information.

Minifying JS – Skip removing line numbers?

App Insights Visual Studio Integration is Fantastic

So, I do love App Insights, but I just realised that it’s even better than I’d thought. They’ve integrated it more closely with Visual Studio.

In the code you can see things at the top of each method – how many references it has, who last edited it, how long ago it was edited,, etc.

Well now you can also see the exceptions that were recorded by App Insights for that method in the last 24 hours:

appinsights-in-visual-studio

Fantastic!

(And all those are expected exceptions. If anyone works out a way of doing a Response.Redirect() without a ThreadAbortException and still killing the page processing, let me know)

App Insights Visual Studio Integration is Fantastic

Make Sitecore record the class writing to the logs

I’m a big fan of writing into your logs the class and method that is currently executing – it makes fault finding so much easier. Typically I’d do this with reflection – but it turns out that you can do this with a small change to Sitecore’s configurationContinue reading “Make Sitecore record the class writing to the logs”

Make Sitecore record the class writing to the logs

Using SPMonitoredScope, Counters and SPCriticalTraceCounter

Something that I don’t always remember – you can use the SPMonitoredScope class to monitor your SharePoint code as it executes. The results then get sent to the Developer Dashboard and ULS logs. There’s a decent description of it on MSDN.

using (new SPMonitoredScope("My Monitored Scope"))
{
    // Do Stuff...
}

Continue reading “Using SPMonitoredScope, Counters and SPCriticalTraceCounter”

Using SPMonitoredScope, Counters and SPCriticalTraceCounter

Allowing logging for a particular app pool

I had a problem that one of our development machines had been configured in a ‘Least Privileges’ configuration – and it was a bit too least. The content app pool could not write to the logs. OWSTimer and WebAnalytics both could, but there was nothing from W3WP for that web app.

Just a reminder to myself…

Well, the solution was to add the app pool account to the ‘Performance Log Users’ group in AD. You find it under BUILTIN. Reset ISS. Voila!

Allowing logging for a particular app pool

My Logging Diagnostics Service for SharePoint 2010

With SharePoint 2010, Microsoft gave us a better framework for logging that SharePoint 2007, which relied on writing most of your own. Sadly, though, the SPDiagnosticsServiceBase does lack in a couple of areas. Consequently, I’ve ended up writing my own Diagnostics service to try and address those issues. I am far from the only one (See the references below), but I’d like to present what I’ve written, not least ‘cos I’ve been meaning to blog about it for about 8 months.

First, though, let’s look at the limitations of the SPDiagnosticsServiceBase. Continue reading “My Logging Diagnostics Service for SharePoint 2010”

My Logging Diagnostics Service for SharePoint 2010

FAIL: SPCriticalTraceCounter and TraceLevels

I’ve been looking at how to use the SPCriticalTraceCounter class for outputting messages in the Developer Dashboard. I came across a good post about how to do this by Frode Aarebrot, but it left me puzzled – what was the traceLevel integer about? Why wasn’t it an enumeration – like the Microsoft.SharePoint.Administration.TraceSeverity enum? Why those magic values? What happened if I used a wrong value?

Continue reading “FAIL: SPCriticalTraceCounter and TraceLevels”

FAIL: SPCriticalTraceCounter and TraceLevels