Skip to content

Remove a property after message render  #335

Open
@StrangeW

Description

@StrangeW

Hello

Is your feature request related to a problem? Please describe.
I'm not sure if this is a Feature, but I'll need to be able to remove a property from the logs once the message is build.

Describe the solution you'd like
In idea, when I run

_logger.LogInformation("I run {ControlerName} at {RunDate}", nameof(HomeController), DateTime.Now);

I would like the message to be I run HomeController at 06/27/2023 17:45:23 but the RunDate property not to be present

{
	"@timestamp": "2023-06-27T17:45:23.0784393+02:00",
	"level": "Information",
	"messageTemplate": "I run {ControlerName} at {RunDate}",
	"message": "I run HomeController at 06/27/2023 17:45:23",
	"fields": {
		"ControlerName": "HomeController",
		"SourceContext": "MyApp.WebApp.Controllers.HomeController",
		"RequestPath": "/",
		"Environment": "DEV",
		"MachineName": "Test",
		"ApplicationName": "MyApp"
	}
}

Additional context
I send my logs to applications like ElasticSearch or AppInsight and each property is indexed. I'd like to do away with these fields.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions