title: Using IndexDecider in Serilogs Elasticsearch Sink
body: <p>Im trying to use a custom indexdecider to set the index name at run time for my serilog elasticsearch sink. (<a href="https://github.com/serilog/serilog-sinks-elasticsearch" rel="nofollow">https://github.com/serilog/serilog-sinks-elasticsearch</a>)</p>
  
  <p>Whichever function I use for the index decider gets ignored and the index name defaults to logstash-yyyy-mm-dd unless I give it another index name pattern. I need it to use the index decider function.</p>
  
  <pre><code>var esConfig = new ElasticsearchSinkOptions(new Uri(elasticSearchLogServer))
         {
             BufferBaseFilename = Path.Combine(logPath, bufferfilename),
             IndexDecider = (@event, offset) =&gt;
                            {
                                var indexNumber = Math.Ceiling((double)offset.Day / 8);
                                var indexName = string.Format("{0}-{1}-{2}-{3:yyyy.MM}-{4}", "logbase", environment, shortAppname, offset, indexNumber);
                                return indexName;
                            }
         };
  var loggerConfiguration = loggerSinkConfiguration.Elasticsearch(esConfig);
  </code></pre>