log4stash 2.2.1

.NET Framework 4.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package log4stash --version 2.2.1
NuGet\Install-Package log4stash -Version 2.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="log4stash" Version="2.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add log4stash --version 2.2.1
#r "nuget: log4stash, 2.2.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install log4stash as a Cake Addin
#addin nuget:?package=log4stash&version=2.2.1

// Install log4stash as a Cake Tool
#tool nuget:?package=log4stash&version=2.2.1

log4stash

log4stash is a log4net appender to log messages to the ElasticSearch document database. ElasticSearch offers robust full-text search engine and analyzation so that errors and messages can be indexed quickly and searched easily.

log4stash provide few logging filters similar to the filters on logstash.

The origin of log4stash is @jptoto's log4net.ElasticSearch repository.

Features:

  • Supports .NET 4.0+ and .NET Core
  • Easy installation and setup via Nuget
  • Ability to analyze the log event before sending it to elasticsearch using built-in filters and custom filters similar to logstash.

Breaking Changes:

Navigate to breaking changes page here. See also Version notes page.

Filters:

  • Add - add new key and value to the event.
  • Remove - remove key from the event.
  • Rename - rename key to another name.
  • Kv - analyze value (default is to analyze the 'Message' value) and export key-value pairs using regex (similar to logstash's kv filter).
  • Grok - analyze value (default is 'Message') using custom regex and saved patterns (similar to logstash's grok filter).
  • ConvertToArray - split raw string to an array by given seperators.
  • Json - convert json string to an object (so it will be parsed as object in elasticsearch).
  • Convert - Available convertors: ToString, ToLower, ToUpper, ToInt and ToArray. See config example for more information.
  • Xml - Parse xml into an object.
Custom filter:

To add your own filters you just need to implement the interface IElasticAppenderFilter on your assembly and configure it on the log4net configuration file.

Issues:

I do my best to reply to issues or questions ASAP. Please use the ISSUES page to submit questions or errors.

Configuration Examples:

Almost all the parameters are optional, to see the default values check the c'tor of the appender and the c'tor of every filter. You can also set any public property in the appender/filter which didn't appear in the example.

Simple configuration:
<appender name="ElasticSearchAppender" type="log4stash.ElasticSearchAppender, log4stash">
    <Server>localhost</Server>
    <Port>9200</Port>
    <ElasticFilters>
      
      <kv /> 
    </ElasticFilters>
</appender>

License:

MIT License

Thanks:

Thanks to @jptoto for the idea and the first working ElasticAppender. Many thanks to @mpdreamz and the team for their great work on the NEST library! The inspiration to the filters and style had taken from elasticsearch/logstash project.

Product Versions
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on log4stash:

Package Downloads
Centralized.Micro.Service.Core

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.4 20,999 7/11/2021
3.0.3 275 7/11/2021
3.0.2 2,542 6/28/2021
3.0.0 124,655 4/12/2020
2.3.0 6,595 4/9/2020
2.2.2-pre 672 1/7/2019
2.2.1 183,239 6/19/2018
2.2.0 1,918 6/19/2018
2.1.0 37,125 11/8/2017
2.0.5 14,975 10/18/2017
2.0.4 68,075 3/20/2017
2.0.2-c 1,251 8/23/2016
2.0.1 29,106 7/10/2016
2.0.0 2,166 5/30/2016
1.1.1 48,117 1/22/2016
1.1.0 4,818 10/10/2015
1.0.2 4,445 4/27/2015
1.0.1 16,083 12/30/2014
1.0.0 2,259 10/9/2014
0.1.0 1,343 9/20/2014

* Supporting .net core 2.
     * Using RestSharp for the ElasticClient instead of legacy code.
     * Update content-type in aws signing code.
    
    * Closed issues:
       ** #26 Make compatible with .NET Core
       ** #40 Error 406 with ElasticSearch 6.0 RC 2
       ** #47 Remove `(Begin/End)GetRequest` async mechanism
     
     * Merged pull requests
       ** #42 Updated the nuspec to support .net core 2.0
       ** #48 Replaced WebRequest with RestSharp
       ** #49 update content-type in aws signing code to application/json for ES 6.0
     
     Thanks a lot to @erangil2 for his tremendous contributions :)
     
     And thanks to: @zhengziying, @triarc, @prime8, @henkish, @mfpalladino, @ignasv, @wpgh, @Thecentury and @pnumainville for their contributions.