-
Notifications
You must be signed in to change notification settings - Fork 67
Description
ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog):
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I want a migration guide from Serilog.Sinks.Elasticsearch where we use a in house ElasticSerch server. We configyre the UR and an IndexFormat
Describe the solution you'd like
A clear and concise description of what you want to happen.
I want our new implementation write loggs to the server as the old one did
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The old implementation:
public class FastProLogger : IFastProLogger
{
private readonly ILogger _seriLogger;
public FastProLogger(IConfiguration configuration)
{
string elasticSearchIndexFormat = configuration["ElasticSearch:IndexFormat"] ?? throw new ApplicationException($"Konfiguration för ElasticSearch:Uri saknas");
string unused = configuration["Logging:LoggDumpFilePath"] ?? throw new ApplicationException($"Konfiguration för Logging:LoggDumpFilePath saknas");
string elasticSearchUri = configuration["ElasticSearch:Uri"] ?? throw new ApplicationException($"Konfiguration för ElasticSearch:Uri saknas");
IConfigurationSection section = configuration.GetSection("ElasticSearch:IndexFormat");
string? sectionValue = section.Value;
ElasticsearchSinkOptions options = new(new Uri(elasticSearchUri))
{
AutoRegisterTemplate = false, // we do not appear to have enough access rights to register templates
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
IndexFormat = elasticSearchIndexFormat,
EmitEventFailure = EmitEventFailureHandling.ThrowException,
RegisterTemplateFailure = RegisterTemplateRecovery.FailSink,
CustomFormatter = new ElasticsearchJsonFormatter()
};
_seriLogger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Elasticsearch(options)
.CreateLogger();
}
public void Debug(string messageTemplate, params object[] propertyValues)
{
_seriLogger.Debug(messageTemplate, propertyValues);
}
...
}