Try our conversational search powered by Generative AI!

Mattias Lövström
Sep 3, 2010
(0 votes)

LinqToSqlLogger as promised

As I promise in my past blog post Troubleshooting database tool – SqlClientLogger that I should deliver a logger for LinqToSql also. This is done and it is also located in the support tools area on EPiServer world.

The changes to LinqToSqlLogger and SqlClientLogger are

1) The installation – it has to be configured as a Http installation Module

2) It requires .Net 3.5 – of cause

3) The log4net logger is named “LinqToSqlLogger”

Known issues

Transactions doesn’t work (yet), this means that saving operations break the logger.


This tool logs every LinqToSql call to the database done by the
application layer with a stack trace and a time it took to execute
the query. The benefits of using this tool is that it prints out
a stack trace so it’s easy to locate what code that generates the
database call. The logs are written to log4net and should appear in
the sites log file.


.Net 3.5


Drop the assemblies in the packages bin/ folder to your sites bin/ folder
Add a reference to the initialization module handler for LinqToSqlLogger in the sites

web.config file
      <add name="LinqToSqlLoggerModule" type="LinqToSqlLogger.InitializeModule, LinqToSqlLogger" />


When the LinqToSqlLogger is installed on the site it is going to send
log4net messages using the logger “LinqToSqlLogger”.

Log4Net logger levels

DEBUG – prints out database command, stack trace and execution time
INFO – prints out database command and execution time.
WARN – prints out database command, stack trace and execution time the execution time is over 500 ms

Sample of how to configure it in the file EPiServerLog.config (or where your log4net configuration is)
  <logger name="LinqToSqlLogger">
    <level value="DEBUG" />

Duration threshold can be set in the appSettings in the web.config file for the keys
SqlClientLoggerDurationFilterMs – a threshold for all logged database calls
SqlClientLoggerDurationWarnFilterMs - a threshold for trigger a warning message, the default is set to 500 ms


Sep 03, 2010


Oct 8, 2010 08:41 AM

I have updated this blog with the contents of the readme file, so you don’t have to extract the zip file each time you need to see how it should be installed (probably bad names/configuration sense I never remember it myself).

Please login to comment.
Latest blogs
From Procrastination to Proficiency: Navigating Your Journey to Web Experimentation Certification

Hey there, Optimizely enthusiasts!   Join me in celebrating a milestone – I'm officially a certified web experimentation expert! It's an exhilarati...

Silvio Pacitto | May 17, 2024

GPT-4o Now Available for Optimizely via the AI-Assistant plugin!

I am excited to announce that GPT-4o is now available for Optimizely users through the Epicweb AI-Assistant integration. This means you can leverag...

Luc Gosso (MVP) | May 17, 2024 | Syndicated blog

The downside of being too fast

Today when I was tracking down some changes, I came across this commit comment Who wrote this? Me, almost 5 years ago. I did have a chuckle in my...

Quan Mai | May 17, 2024 | Syndicated blog

Optimizely Forms: Safeguarding Your Data

With the rise of cyber threats and privacy concerns, safeguarding sensitive information has become a top priority for businesses across all...

K Khan | May 16, 2024

The Experimentation Process

This blog is part of the series -   Unlocking the Power of Experimentation: A Marketer's Insight. Welcome back, to another insightful journey into...

Holly Quilter | May 16, 2024

Azure AI Language – Sentiment Analysis in Optimizely CMS

In the following article, I showcase how sentiment analysis, which is part of the Azure AI Language service, can be used to detect the sentiment of...

Anil Patel | May 15, 2024 | Syndicated blog