EasyELK 1.0.1

An easy way to send logs to an ELK stack

Install-Package EasyELK -Version 1.0.1
dotnet add package EasyELK --version 1.0.1
<PackageReference Include="EasyELK" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyELK --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

EasyELK

An easy way to send log entries from your application directly to your existing ELK (Elasticsearch, Logstash, Kibana) stack. I´m assuming, that you already have configured your ELK properly. If you did not ... well it might happen, that EasyELK is not able to send log entries correctly.

Implement EasyELK

After loading the nuget package the implementation is quite simple.
First you have to generate a logger object. It´s on your side, if you want to use it as a singleton or global or whatever.

EasyELK.Log2ELK elkLogger = new Log2ELK(elasticsearchurl, localLogFile,instanceName,minimalLogLevel,showConsole);

The params from first to last are meaning the following:

  1. {string} elasticsearchurl:

    The URL of your elasticsearch instance. Be sure to send it with http:// (or https://) and the correct port e.g. http://192.168.1.10:9200

  2. {string} localLogFile:

    The complete path where you want to store a fallback logfile where EasyELK is running. The logfile will only be written into, when something went wrong during sending your log to elasticsearch

  3. {string} instanceName:

    The name of your instance e.g. your machine name or something. This is necessary to find and filter specific log entries later in Kibana by the instance name.

  4. {enum LOGLEVEL} minimalLogLevel:

    The minimum log level which should EasyELK listen to. You find an order of the possible levels below

  5. {bool} showConsole:

    True if you want to also watch log messages in a separate console window, false if not

Log Levels

  • 0 = Verbose
  • 1 = Debug
  • 2 = Information
  • 3 = Warning
  • 4 = Error
  • 5 = Fatal

IMPORTANT: Be aware, that you using the minimal loglevel that you expect. Log messages below your minimum level will not be sent. For example if you set your minimal log level to Warning, and you send an Verbose message, the Verbose message will be ignored.

Sending a Log Message

Sending a log message whenever you want directly from your code just by using the following line of code

elkLogger.WriteLogEntry(logLevel, logMessage, template);
  1. {enum LOGLEVEL} logLevel:

    The level of your log entry that should be listed in Kibana

  2. {string} logMessage:

    The message you want to be transferred to Elasticsearch.

  3. {string} template:

    A template name which you can filter your entries later in Kibana. e.g. if you want to send a connection exception, simply name it "ConnectionException". You can then filter your exception messages by this template name as well as your index name, you defined when the object is instanced.

EasyELK

An easy way to send log entries from your application directly to your existing ELK (Elasticsearch, Logstash, Kibana) stack. I´m assuming, that you already have configured your ELK properly. If you did not ... well it might happen, that EasyELK is not able to send log entries correctly.

Implement EasyELK

After loading the nuget package the implementation is quite simple.
First you have to generate a logger object. It´s on your side, if you want to use it as a singleton or global or whatever.

EasyELK.Log2ELK elkLogger = new Log2ELK(elasticsearchurl, localLogFile,instanceName,minimalLogLevel,showConsole);

The params from first to last are meaning the following:

  1. {string} elasticsearchurl:

    The URL of your elasticsearch instance. Be sure to send it with http:// (or https://) and the correct port e.g. http://192.168.1.10:9200

  2. {string} localLogFile:

    The complete path where you want to store a fallback logfile where EasyELK is running. The logfile will only be written into, when something went wrong during sending your log to elasticsearch

  3. {string} instanceName:

    The name of your instance e.g. your machine name or something. This is necessary to find and filter specific log entries later in Kibana by the instance name.

  4. {enum LOGLEVEL} minimalLogLevel:

    The minimum log level which should EasyELK listen to. You find an order of the possible levels below

  5. {bool} showConsole:

    True if you want to also watch log messages in a separate console window, false if not

Log Levels

  • 0 = Verbose
  • 1 = Debug
  • 2 = Information
  • 3 = Warning
  • 4 = Error
  • 5 = Fatal

IMPORTANT: Be aware, that you using the minimal loglevel that you expect. Log messages below your minimum level will not be sent. For example if you set your minimal log level to Warning, and you send an Verbose message, the Verbose message will be ignored.

Sending a Log Message

Sending a log message whenever you want directly from your code just by using the following line of code

elkLogger.WriteLogEntry(logLevel, logMessage, template);
  1. {enum LOGLEVEL} logLevel:

    The level of your log entry that should be listed in Kibana

  2. {string} logMessage:

    The message you want to be transferred to Elasticsearch.

  3. {string} template:

    A template name which you can filter your entries later in Kibana. e.g. if you want to send a connection exception, simply name it "ConnectionException". You can then filter your exception messages by this template name as well as your index name, you defined when the object is instanced.

Release Notes

Initial release

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 116 2/26/2019