log4stash 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package log4stash --version 2.2.0
NuGet\Install-Package log4stash -Version 2.2.0
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.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add log4stash --version 2.2.0
#r "nuget: log4stash, 2.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.0

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

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 3.5+
  • 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 Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on log4stash:

Package Downloads
TylerHelp

山河辽阔,人间星河,无一是你,无一不是你。

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 59,822 7/11/2021
3.0.3 943 7/11/2021
3.0.2 5,045 6/28/2021
3.0.0 162,505 4/12/2020
2.3.0 7,703 4/9/2020
2.2.2-pre 1,379 1/7/2019
2.2.1 212,850 6/19/2018
2.2.0 3,678 6/19/2018
2.1.0 42,753 11/8/2017
2.0.5 21,022 10/18/2017
2.0.4 91,822 3/20/2017
2.0.2-c 1,959 8/23/2016
2.0.1 34,621 7/10/2016
2.0.0 3,008 5/30/2016
1.1.1 50,224 1/22/2016
1.1.0 5,666 10/10/2015
1.0.2 6,056 4/27/2015
1.0.1 25,572 12/30/2014
1.0.0 3,096 10/9/2014
0.1.0 2,137 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.