S.L.A.B. To ElasticSearch

I always like to find new ways to not write the same code twice. Logging has been one of those features that every application needs, and every application does it differently. Do you log to SQL, a text file, for how long, what format?

The Semantic Logging Application Block supports SQL, Azure, ElasticSearch or any other “Sink” you want to write. It supports buffering, retry for when a Sink isn’t available. Awesome, all the stuff I want but don’t need to write my own version of. More details on SLAB here, Semantic Logging Application Block @ CodePlex

So how do you use this wonderful tool?

1. Install ElasticSearch. It is more like an XCopy deploy then an MSI Install. Installing ElasticSearch @ ElasticSearch.org

2.  Install the template from ElasticSearch Sink to help ElasticSearch understand your log messages.

3.Download the Nuget Packages,

PM > Install-Package EnterpriseLibrary.SemanticLogging.Elasticsearch

4. Put this Gist into your code somewhere and point it to your ElasticSearch server. Make sure your log type matches the one used in the ElasticSearch Template. Best to just use “etw” as below.

[gist id=”7e367d7bf5fbcab5129c” synhi=true lang=”csharp”]

5. Log an error


6. Done.

Next post I will show how to use two different ElasticSearch plugins to monitor and view your errors.

Leave a Reply

Your email address will not be published. Required fields are marked *