sitecoreops/sitecore-logging-extensions

Would MDC Values be included as Properties of a LoggingEvent?

Closed this issue ยท 3 comments

I know this is quite an old project so is probably not supported any longer, but I wondered if it was possible to ask something ๐Ÿ˜ƒ

Would a key value pair added to the MDC be included in the JSON, as part of the "loggingEvent.Properties" in the Layout.cs file here?
Does Log4Net roll them up as part of the CreateCompositeProperties() call?

I'm trying to figure out how to include some values that our monitoring tool should be auto-adding but I'm finding it tricky to track down where they put it in the first place, based on their documentation for Log4J I'm assuming it is in the MDC though!

They say the auto enrichment should work with Log4Net 2.0.6+ but I don't know exactly which version of Log4Net is in use for us, as I think Sitecore.Logging might hide that detail now - we're using Sitecore.Logging 9.1.1 on Sitecore 9.1 if that makes a difference though.

Thanks!

Hi, thanks for reaching out, I don't know about MDC but I do know that the embedded version of log4net in Sitecore.Logging is unfortunately VERY VERY old, it's version 1.2.0.30715 as far as I know, even in latest version 10.4.0 of Sitecore platform. So I'm pretty sure your auto enrichments provided by your monitoring tool will not work :-/

As an alternative you can maybe switch out Sitecore log4net implementation with something else, such as Microsoft.Extensions.Logging, see how it can be done here:

Thanks Per, appreciate the quick reply!

That knowledge about the old log4net version will have saved me a lot of time (and hair pulling) so thankyou!

I'll have a look into that alternative of the Microsoft Extensions logging, version 3.0.0+ is supported by the monitoring agent, so maybe the Microsoft Extensions Logging package will possibly need to be updated in the project (looks like we have 2.1.1 at the moment). I'll ask our dev team for some assistance with that and the changes you highlighted....I'm not a developer so they will understand them better than I do!

Thanks again!

No problem and good luck ๐Ÿ™‚