Using Serilog with Elastic APM causes NullReferenceException
See original GitHub issueDescribe the bug When using Serilog and Elastic APM together in Asp.Net COre, a NullReferenceException is thrown on start-up.
Versions: netcoreapp 2.1 Elastic.Apm.NetCoreAll 1.1.1 Serilog.AspnetCore 3.0.0
To Reproduce Steps to reproduce the behavior:
- Clone this repo: https://github.com/scotmeiste/elastic-apm-serilog-error
- in appsettings.json, replace ServerUrls and SecretToken with your instance of Elastic APM
- Run Web Api project
- See error in debug output (Debug Console tab in VS Code)
Elastic APM .NET Agent: [CRITICAL] Exception thrown by logging implementation. Log message: `The agent was started without a service name. The automatically discovered service name is {ServiceName}'. args.Length: 1. Current thread: managed ID: 1
Elastic APM .NET Agent: +-> Exception (exception): System.NullReferenceException: Object reference not set to an instance of an object.
Elastic APM .NET Agent: at Serilog.Extensions.Logging.SerilogLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Elastic.Apm.AspNetCore.AspNetCoreLogger.Log[TState](LogLevel level, TState state, Exception e, Func`3 formatter)
at Elastic.Apm.Logging.LoggingExtensions.DoLog(IApmLogger logger, LogLevel level, String message, Exception e, Object[] args)e: <null>
Expected behavior Either no error, or a more helpful description of what went wrong.
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (10 by maintainers)
Top Results From Across the Web
Using Serilog with Elastic APM causes ...
Describe the bug When using Serilog and Elastic APM together in Asp.Net COre, a NullReferenceException is thrown on start-up.
Read more >Serilog | APM .NET Agent Reference [1.x]
We offer a Serilog Enricher that adds the trace id to every log line that is created during an active trace. The enricher...
Read more >Developers - Using Serilog with Elastic APM causes ...
Using Serilog with Elastic APM causes NullReferenceException.
Read more >Serilog does not send log to Elasticsearch asp.net core
I'm using Serilog and Elasticearch For my asp.net core app but when I open Kibana ... TypeName = null, AutoRegisterTemplate = true, ...
Read more >Logging With ElasticSearch, Kibana, Serilog Using ASP. ...
In this article, I'll show you how to set up and run your application using ElasticSearch, Kibana and Serilog.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@scotm-gxg: The patch with the fix is out: https://github.com/elastic/apm-agent-dotnet/releases/tag/1.1.2 - so
1.1.2
should be ok with Serilog. The packages are also updated on nuget.org.Awesome!
Regarding release: we already have 2 fairly important fixes on master. We don’t make promises on release dates, but I think having those 2 fixes out there would be important, so I’m thinking about a patch release very soon.