bruno-garcia / log4net.ElasticSearch

log4net appender to ElasticSearch
https://bruno-garcia.github.io/log4net.ElasticSearch/
Other
220 stars 92 forks source link

Add Custom Fields #93

Closed MonsieurMix closed 6 years ago

MonsieurMix commented 6 years ago

Hello,

I make a POC on ELK and try log4net.ElasticSearch. because I have been using log4net for years and we use it in all .Net Project in my company.

We share ELK with PHP Frontend team and want to normalise ELK between 2 teams. We decide to put a mandatory special field named "Component".

Btw, I try to add it with log4net.ElasticSearch but I can't... In documentation I read "06 Adding Custom Data" but in this way, field named "exception.Data.component" not just "Component" and I try log4net standard custom data adding : log4net.LogicalThreadContext.Properties["component"] = "PocElkConsole" but in this way field name "properties.component".

Thanks for your help.

Regards,

jptoto commented 6 years ago

@MonsieurMix there isn't a way to add a "Component" field at the root, that is what the exception.data field is for. In this way, it keeps the log4net event as pure as possible as it was designed. And then when you want to add custom data, you can use the parts of the event that are dedicated to that. This guarantees each log4net event looks as it was intended.