EasyELK 1.0.1
dotnet add package EasyELK --version 1.0.1
NuGet\Install-Package EasyELK -Version 1.0.1
<PackageReference Include="EasyELK" Version="1.0.1" />
paket add EasyELK --version 1.0.1
#r "nuget: EasyELK, 1.0.1"
// Install EasyELK as a Cake Addin #addin nuget:?package=EasyELK&version=1.0.1 // Install EasyELK as a Cake Tool #tool nuget:?package=EasyELK&version=1.0.1
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:
{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
{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
{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.
{enum LOGLEVEL} minimalLogLevel:
The minimum log level which should EasyELK listen to. You find an order of the possible levels below
{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);
{enum LOGLEVEL} logLevel:
The level of your log entry that should be listed in Kibana
{string} logMessage:
The message you want to be transferred to Elasticsearch.
{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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
- Elasticsearch.Net (>= 6.5.0)
- Polly (>= 7.0.2)
- Serilog (>= 2.8.0)
- Serilog.Sinks.Console (>= 3.1.1)
- Serilog.Sinks.Elasticsearch (>= 7.1.0)
- Serilog.Sinks.File (>= 4.0.0)
- Serilog.Sinks.RollingFile (>= 3.3.0)
- Serilog.Sinks.RollingFile.Extension (>= 2.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 684 | 2/26/2019 |
Initial release