Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serializing exceptions like Serilog.Sinks.Elasticsearch #158

Open
AlexGoris-KasparSolutions opened this issue Jul 5, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@AlexGoris-KasparSolutions

Potential dupe of #139 , but am still facing the same issue with Serilog on 1.5.3

ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog): Elastic.CommonSchema.Serilog

ECS schema version (e.g. 1.4.0): 1.5.3

ECS .NET assembly version (e.g. 1.4.2): 1.5.3

Elasticsearch version (if applicable): 7.13.1

.NET framework / OS: .NET 5.0 / windows 10

Description of the problem, including expected versus actual behavior:
When using ECS with Serilog, exception properties are not sent to ES. I expect to see various exceptions.* properties in my log messages.

Steps to reproduce:
I'm configuring Serilog with the ES sink like so:

var elasticSinkOptions = new ElasticsearchSinkOptions(new Uri(elasticSettings.Uri))
{
    AutoRegisterTemplate = true,
    IndexFormat = $"logs-{indexName}",
    BatchAction = ElasticOpType.Create,
    CustomFormatter = new EcsTextFormatter()
};
Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .Enrich.FromLogContext()
    .Enrich.WithProperty("Application", "MyService")
    .WriteTo.Elasticsearch(elasticSinkOptions)
    .WriteTo.Console(outputTemplate:
        "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}");

When doing e.g.:

try
{
    throw new Exception("Some exception");
}
catch (Exception e)
{
    Log.LogError(e, "Error occurred");
}

The log is sent to ES, but does not include information about the exception, the custom property (.Enrich.WithProperty("Application", "MyService")), does get sent to ES.
When removing CustomFormatter = new EcsTextFormatter() from the ES sink configuration, the exception does get sent to ES (in the exceptions.* properties), but my custom property not anymore.

@AlexGoris-KasparSolutions AlexGoris-KasparSolutions added the bug Something isn't working label Jul 5, 2021
@AlexGoris-KasparSolutions
Copy link
Author

I did some more research since this problem is really starting to annoy us.
1.5.1 does not have this problem, neither does 1.6.1-alpha1.

Any schedule on a non-prerelease of 1.6.1?

@fabianrieder
Copy link

I also do still have the same issue as mentioned in #139 . Current Installed version is 1.5.3

@Mpdreamz Mpdreamz changed the title No exceptions logged to ES using when using Serilog Support serializing exceptions like Serilog.Sinks.Elasticsearch Feb 10, 2023
@Mpdreamz
Copy link
Member

Thanks for reporting this took me a while to parse this is actually a feature request to suppot the exceptions.* property just like Serilog.Sinks.Elasticsearch. A feature I actually contributed there back in '15 🐱

Here's an old gist of that output:

https://gist.github.com/Mpdreamz/9fe1e18aca522f50b702

exceptions.* is not ECS compliant. Today ECS has no notion of serializing stack frames although it did add error.stack_trace since our last release:

elastic/ecs#562

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants