Skip to content

[FEATURE] #493

@seurhe

Description

@seurhe

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);
    }
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions