markmcdowell / NLog.Targets.ElasticSearch

NLog target for Elasticsearch
MIT License
176 stars 89 forks source link

EventId duplication #141

Closed Sirozha1337 closed 3 years ago

Sirozha1337 commented 3 years ago

When logging messages like this: logger.LogError(new EventId(1, "Test"), "some message") The following Json object gets logged in ElasticSearch:

{
   "level": "Error",
   "message": "some message",
   "EventId_Id": 1,
   "EventId_Name": "Test",
   "EventId": {
       "Id": 1,
       "Name": "Test"
   }
}

The same information about the event gets logged twice.

Is this a bug or the intended behaviour?

snakefoot commented 3 years ago

It is caused by NLog.Extensions.Logging, that captures the EventId many times:

The goal is to remove EventId-property, since it will actually introduces additional boxing overhead, but is a breaking change and waiting for NLog 5.0. See also: https://github.com/NLog/NLog.Extensions.Logging/pull/319

The ElasticSearch-Target has the option ExcludedProperties that might be useful until getting to NLog 5.0 RTM.

Sirozha1337 commented 3 years ago

@snakefoot thanks for the quick response. I used the ExcludedProperties option to remove duplicated fields. Should I close this issue or will you close it when it gets fixed by NLog team?

snakefoot commented 3 years ago

Closing the issue is fine, since not for this repository.