Centralized on premise real time log management for .NET, JavaScript and other technologies.

The other day, I was trying to come up with a centralized, real time error and log reporting solution and came across this https://exceptionless.com/. After some R&D I found it to be a perfect in premise free log management tool that goes really well with the entire .NET stack and javascript.
There is an online version of same provided by ExceptionLess, but I am going to describe the process for self hosting. ExceptionLess has 2 key components :

  1. API to receive logs, messages and events. The core is written in .NET as a WEB API and supported by mangoDB, redis and ElasticSearch in the backend.
  2. A dashboard application written in angular.js that makes calls to the API and provides a decent enough dashboard to browse logs.

Each project has its own API key so we can be sure that the logs are separate for each project/module and the dashboard has enough filters to separate them out. So we can have logs of different projects with proper access control on the same dashboard.
At the time of this blog, I used version 2.1 and the notes below are based on that. Version 3.0 will be out soon and make internal hosting better. For those who do not want internal hosting, I recommend using ExceptionLess hosting. More details can be found here : http://exceptionless.com/pricing
The installation is really straight forward as with any .NET site.

  • Install MongoDB, Redis Server, ElasticSearch and IIS url rewrite on the server.

Download the API code from https://github.com/exceptionless/Exceptionless then rebuild/publish the API on IIS.

Update the connection strings in the Web.config file to point to your Elasticsearch and Redis servers. If you are doing everything on the same server then the standard ports are 6379 for redis and 9200 for elasticSearch.
Update the app settings (BaseURL, EnableSSL, WebsiteMode, etc) in the Web.config file. For me these were http://serverDNS or http://serverIP , SSL = false and mode = “Production”
Update the mail settings in the Web.config file. I was using my own SMTP server so I updated it to this and all the emails worked fine.

<mailSettings>
<smtp from=”no-reply@no-reply.com”>
<network host=”smtp.live.com” password=”mypasswordgoeshere” port=”587″ userName=”MyEmail@live.co.uk” enableSsl=”true”/>
</smtp>
</mailSettings>

Update the machineKey in the web.config file. You can use this link to generate a new one.http://www.a2zmenu.com/utility/Machine-Key-Generator.aspx
Update the ‘BaseURL’ to the UI url I am setting up next.
To install the angular frontend using the release here : https://github.com/exceptionless/Exceptionless.UI/releases
Update the app.config.*.js file with your settings. the key here is the BaseUrl. This should point out to the API url.
The first user I signed as, became the UI admin.
So my final API layer web.config is like this :

<connectionStrings>
<add name=”RedisConnectionString” connectionString=”127.0.0.1:6379″ />
<add name=”ElasticSearchConnectionString” connectionString=”http://localhost:9200&#8243; />
</connectionStrings>
<appSettings>
<!– Base url for the ui used to build links in emails and other places. –>
<add key=”BaseURL” value=”http://xxx.xxx.xxx.xxx:8081/&#8221; />
<!– Controls whether SSL is required. Only enable this if you have SSL configured. –>
<add key=”EnableSSL” value=”false” />
<!–
Dev: Use this mode when debugging. (Outbound emails restricted)
QA: Use this mode when deployed to staging. (Outbound emails restricted)
Production: Use this mode when deployed to production.
–>
<add key=”WebsiteMode” value=”Production” />
and app.config file on the UI layer is like this :
(function () {
“use strict”;
angular.module(‘app.config’, [])
.constant(‘BASE_URL’, ‘http://xxx.xxx.xxx.xxx/api/v2&#8242;)
.constant(‘FACEBOOK_APPID’, ”)
.constant(‘GITHUB_APPID’, ”)
.constant(‘GOOGLE_APPID’, ”)
.constant(‘INTERCOM_APPID’, ”)
.constant(‘LIVE_APPID’, ”)
.constant(‘STRIPE_PUBLISHABLE_KEY’, ”)
.constant(‘SYSTEM_NOTIFICATION_MESSAGE’, ”)
.constant(‘USE_HTML5_MODE’, true)
.constant(‘USE_SSL’, false)
.constant(‘VERSION’, ‘2.0.441’)
;
}());
you can also enable API layer debugging by using nLog.
to do that i just updated my web.config with this setting :
<configSections>
<section name=”exceptionless” type=”Exceptionless.ExceptionlessSection, Exceptionless.Extras” />
<section name=”nlog” type=”NLog.Config.ConfigSectionHandler, NLog”/>
</configSections>
<nlog xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
<targets>
<!– Daily log files, deleted after 7 days –>
<target name=”Search.Web” xsi:type=”File” fileName=”C:\inetpub\wwwroot\errors.web.log” archiveFileName=”C:\inetpub\wwwroot\errors.web.{#}.log” archiveEvery=”Day” archiveNumbering=”Rolling” maxArchiveFiles=”7″ />
</targets>
<rules>
<logger name=”*” minlevel=”Info” writeTo=”Search.Web” />
</rules>
</nlog>

Then there are a lot of samples to make a call to the api and see results on dashboard.
https://github.com/exceptionless/Exceptionless.Net
but in summary you have to do the settings as per below –
Install ExceptionLess using Nuget package manager.
Then update config file

<exceptionless apiKey=”YOUR_API_KEY” serverUrl=”http://localhost&#8221; enableSSL=”false” />

Or using Exceptionless.Configuration;

[assembly: Exceptionless(“YOUR_API_KEY”, ServerUrl = “http://localhost&#8221;, EnableSSL = false)]

API_KEY here is provided to you when you create a new project on UI.
and then make calls to the API to submit logs,events or messages.