question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Framework: Configuring Enrichers from json does not work

See original GitHub issue

Does this issue relate to a new feature or an existing bug?

  • Bug
  • New Feature

What version of Serilog is affected? Please list the related NuGet package. Serilog, Version=2.0.0.0 Serilog.Enrichers.Process, Version=2.0.0.0 Serilog.Enrichers.Thread, Version=2.0.0.0 Serilog.Enrichers.Environment, Version=2.0.0.0 Serilog.Settings.Configuration, Version=2.6.1.0

What is the target framework and operating system? See target frameworks & net standard matrix.

  • netCore 2.0
  • netCore 1.0
  • 4.7
  • 4.6.x
  • 4.5.x

Please describe the current behavior? Enrichers configured via json configuration are not applied. The created logger has an empty enricher.

Please describe the expected behavior? The enrichers specified in the json config should be applied to the created logger and the data they are supposed to add gets put in the logs

If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem This is the config section I have

"Serilog": {
	"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId", "WithExceptionDetails" ],
	"MinimumLevel": "Verbose",
	"WriteTo": [
		{
			"Name": "Trace",
			"Args": {
				"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
			}
		}
	],
	"Using": [ "Serilog.Sinks.Trace" ]
}

We’re using the full .NET Framework. The logger creation looks like this. We load it entirely from the IConfiguration object.

var logger = new LoggerConfiguration()
	.ReadFrom.Configuration(config)
	.CreateLogger();

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nblumhardtcommented, Jul 25, 2018

Ah, yes, the “Using” blocks are only redundant in Core, IIRC the dependency context works differently on Framework 😕

0reactions
skomis-mmcommented, Dec 13, 2019

Hi, @mikeblas . Just checked with 3.1 - works as expected. Can you provide your setup or minimal code that reproduce this? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serilog in .Net: Adding custom enricher via appSettings. ...
1 Answer 1 ... You have to include the name of your assembly in the "Using" section. ... Using section contains list of...
Read more >
Setting up Serilog in ASP.NET Core - Detailed Beginner ...
This article covers the implementation of Serilog in ASP.NET Core which provides structured logging that is easier to be read by programs.
Read more >
Serilog.Enrichers.ClientInfo 2.0.0
Configure the header name and default header name is x-correlation-id; Set value for correlation id when the header is not available in request...
Read more >
Serilog in ASP.NET Core 3.1 - Structured Logging Made ...
In this article, let's go through Serilog in ASP.NET Core 3.1 and it's implementations. Now by default, ASP.NET Core comes with some basic...
Read more >
How To Implement Serilog In ASP.NET Core Web API
NET 6.0 is selected in Framework dropdown additional information page ... Open appsettings.json, and Change the code in that file, which is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found