Skip to content

SamhammerAG/Samhammer.Logging.Logstash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Samhammer.Logging.Logstash

Usage

This package is a implementation of the serilog http sink https://github.com/FantasticFiasco/serilog-sinks-http to use logstash.

How to add this to your project:

Example:

   public static void ConfigureLogger(HostBuilderContext context, LoggerConfiguration logger)
   {
       var elasticIndexPlaceholders = new Dictionary<string, string>
       {
           { "{environment}", context.HostingEnvironment.EnvironmentName },
       };
           
       logger.WriteTo.Logstash(context.Configuration, elasticIndexPlaceholders)            
   }

Example appsettings configuration:

  "Serilog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Warning",
        "System": "Warning",
        "HealthChecks.UI": "Fatal"
      }
    },
    "Logstash": {
      "Url": "<YOUR_LOGSTASH_URL>",
      "UserName": "<YOUR_LOGSTASH_USERNAME>",
      "Password": "<YOUR_LOGSTASH_PASSWORD>",
      "ElasticIndex": "<YOUR_ELASTIC_INDEX_TEMPLATE>"
    }
  },

Example elastic index template:

projectname-{environment}-{brand}

The placeholders in the elastic index template will be replaced with the values of the placeholders dictionary.

Contribute

How to publish package

  • Create a tag and let the github action do the publishing for you