diff --git a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs
new file mode 100644
index 00000000..1928254a
--- /dev/null
+++ b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs
@@ -0,0 +1,336 @@
+using System;
+using System.Collections.Generic;
+
+namespace Serilog.Sinks.Elasticsearch
+{
+ ///
+ ///
+ ///
+ public enum AutoRegisterTemplateVersion
+ {
+ ///
+ /// Elasticsearch version <= 2.4
+ ///
+ ESv2 = 0,
+ ///
+ /// Elasticsearch version <= version 5.6
+ ///
+ ESv5 = 1,
+ ///
+ /// Elasticsearch version >= version 6.0
+ ///
+ ESv6 = 2
+ }
+
+ ///
+ ///
+ ///
+ public class ElasticSearchTemplateProvider
+ {
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static object GetTemplate(
+ Dictionary settings,
+ string templateMatchString,
+ AutoRegisterTemplateVersion version = AutoRegisterTemplateVersion.ESv2)
+ {
+ switch (version)
+ {
+ case AutoRegisterTemplateVersion.ESv5:
+ return GetTemplateESv5(settings, templateMatchString);
+ case AutoRegisterTemplateVersion.ESv6:
+ return GetTemplateESv6(settings, templateMatchString);
+ case AutoRegisterTemplateVersion.ESv2:
+ return GetTemplateESv2(settings, templateMatchString);
+ default:
+ throw new ArgumentOutOfRangeException(nameof(version), version, null);
+ }
+ }
+
+ private static object GetTemplateESv6(
+ Dictionary settings,
+ string templateMatchString)
+ {
+ return new
+ {
+ template = templateMatchString,
+ settings = settings,
+ mappings = new
+ {
+ _default_ = new
+ {
+ dynamic_templates = new List