Mattias Lövström
Sep 3, 2010
  5807
(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.

LinqToSqlLogger

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.

Requirements

.Net 3.5
Log4Net

Installation

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
Example:
<configuration>
  …
  <system.webServer>
    …
      <add name="LinqToSqlLoggerModule" type="LinqToSqlLogger.InitializeModule, LinqToSqlLogger" />

Usage

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)
<log4net>
  ...
  <logger name="LinqToSqlLogger">
    <level value="DEBUG" />
  </logger>

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

Download

LinqToSqlLogger.zip

Sep 03, 2010

Comments

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
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024