Introducing LogBook

I recently wanted to add some basic logging into an MVC Web Project, but all of the big offerings like Elmah and Log4Net are too bloated, so I decided to write a minimalistic logging tool of my own.

Author Avatar

Author: Tom McClean

Updated: 08 Mar 2017 18:30

The Problem

I have been maintaining several websites that use my technology called "Portal CMS" for a while now, but one thing the technology did not do particularly well was reporting errors that happen while users are browsing the website.

To solve this problem I looked at using some of the well known libraries that a lot of people use for logging in their applications; such as Elmah and Log4Net.

The problem I had with the technologies that are most recommended is that they are far too bloated for me to be comfortable using. Elmah for example has some really great features, but isn't particularly easy to configure and I don't want most of the features it offers out of the Box, I simply want to be able to log exceptions and pieces of Information and thats it.


The Solution

In order to solve the gap in logging within Portal CMS in the most minimalist way possible - so as not to bloat Portal CMS. I decided to write my own tiny Logging Library.

I wrote LogBook to be consumable in just 2 lines of code, and to only contain the features you absolutely need from a logger. LogBook therefore can log any information you want which you can classify as an "Error", "Warning" or just "Information". When added to the Application_Error method in an MVC website it will log out the full detail of an exception in just a single line of code.

So LogBook does logging in a really simple way, it also does retrieval of those errors in just as easy a way. LogBook has a few different methods which can be used to retrieve the entries logged in your website, such as Receiving the latest X number of entries, retrieving paged results on demand and a couple of small dashboard suited methods which return a number of errors in a specified time period.

Thats it, simple, just what you might want and comsumed with the least effort possible. You don't even need to run any deployment scripts to get it working as it sets itself up when you use it.


Example Implementation

This example implementation shows the integration between LogBook and my other technology called Portal CMS. I use LogBook to write log entries and Portal CMS reads them back and displays them on a Dashboard.

To start with I have an Analytics Dashboard where I added a new Graph for Errors vs Requests.

Then when the user wants to view more fine detail they can click the "More Details" button and see a list of all of the most recent log entries.

Finally in order to see what exactly went wrong, you can click "Review Exception" to actually see the nitty gritty about what went wrong.

In terms of getting my website to log errors, I just needed to add a small snippet of code into my Global.ASAX.


Do you want to try LogBook?

I released LogBook on GitHub (Including Travis CI) and also listed it within NuGet, so if you are using the same stack (C# MVC, Entity Framework and SQL Server) it might be suited to your needs too. To find out simply search NuGet for "tommcclean.LogBook" or run the command "Install-Package tommcclean.LogBook" in the Package Manager Console to get it installed in your application.

Even if it doesn't work out, you will have only invested 10 minutes in finding out.

You need to Login or Register to comment.

Gallery Image Gallery Image Gallery Image Gallery Image

New Project: XContext

Find out how I decided to cut down my SQL Azure costs on Microsoft Azure.

Tips and Tricks

Implementing Effort into a C# MVC Website to allow Unit Testing

I recently wanted to have the ability to write Unit Tests for a personal project, I picked Effort.EF6 to help. This post goes through the setup for "Effort" and why you should choose it.

Portal CMS

Portal CMS Demo Website Now Available

I wanted to make it as easy as possible to try out Portal CMS. So I have setup a demo website you can login to and try it out!

Portal CMS

User Experience Improvements to the Portal CMS Page Builder

We recently made some changes to the Page Builder in Portal CMS to make it easier and quicker to use. Learn more about what has changed inside this post.


Summer Holiday in Thassos, Greece

I just returned from a holiday in Thassos in Greece, so I wanted to post up some photo's to show what I got up too!


What is SendGrid?

As somebody who develops quite a lot of websites, I find that most of the time I tend to use a lot of the same technologies and services. A lesser known service which I have come to love is called SendGrid, heres why I love it.

Portal CMS

Inline Editing in Portal CMS

I recently releasd a huge change to the Portal CMS technology I have been working on. The ability to change content just like you do offline in Microsoft Office. No need to save changed, nor wait for changes to be made.

Tips and Tricks

How to setup a Web App on Microsoft Azure

A how to guide to creating a Web App on Microsoft Azure, deploying it using Continuous Deployment and hooking it up to a database.

Portal CMS

Portal CMS - Promotional Website

I decided to make a standalone website for Portal CMS; the technology I wrote to sit behind this website and many others. Why not take a look and see what its about?


Website Relaunch

Welcome to my personal website. I am just in the process of relaunching it under my new technology called Portal CMS.

Tips and Tricks

Cost Effective Email Hosting for Custom Domains (Migrated)

This article takes a look at options for setting up multiple email accounts for multiple custom domains.

Portal CMS

Portal CMS - Page Builder Demo

Portal CMS is my latest technology, this article shows a video demonstration of the new technology in action.


Windows 10 - Initial Reaction (Migrated)

This article covers my initial reaction to Windows 10 after using it on my main computer for a few days.


Windows 10 - Coming soon (Migrated)

A brief look at the upcoming Windows 10 release and a look at the new features in the update.