ecs-dotnet
ecs-dotnet copied to clipboard
Support serializing exceptions like Serilog.Sinks.Elasticsearch
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.
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?
I also do still have the same issue as mentioned in #139 . Current Installed version is 1.5.3
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 :cat:
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:
https://github.com/elastic/ecs/pull/562