By default, Azure Functions adds logging context data to all logs. Is it possible to add other context items to be logged globally? Specifically, I'd like to add global data such as the build number. I can't find any sort of hooks that don't require a third party logging framework such as Serilog, but clearly the support is there.
For clarification, I'd like this to be a general solution, not tied to any sink specifically. I'm using Seq, Stackify and Application Insights in various projects.
You can create a custom
ITelemetryInitializerthat will add additional properties.Here I've created an appsetting called
BuildNumber:And a TelemetryInitializer than will get additional properties from the configuration.
Last thing is to register the TelemetryInitializer:
I can now see the BuildNumber on the app insights telemetry: