Open HaGGi13 opened 1 year ago
I am sorry, this should be added to the Arc4u project and not Guidance. If this is an issue, may I ask you to move this issue to the Arc4u project?
I have no clue why this was marked as a bug instead of an enhancement, as I have had selected the "new feature" template, but do you have any progress or ideas to share on that?
Thanks.
Is your feature request related to a problem? Please describe.
In our project we use the Serilog Splunk sink to ingest log messages into Splunk. Unfortunately we noticed the message's meta-data field
host
was not set properly. As this field's value should contain the host machine name, it must be determined on runtime to avoid hard-coding it as the service/application will be deployed on many different servers.This issue was already addressed in the serilog-contrib/serliog-sinks-splunk issue backlog:
Describe the solution you'd like
The best solution we can get is that the Serilog sink used supports this. If they don't implement this like requested in following issue, we can contribute and implement this by our own.
Describe alternatives you've considered
Until this is supported by the extension used, a workaround can be applied like following. After the configuration (
appsettings.json
) is loaded in memory, it can be extended by the needed information. To do so we have to check if a Splunk ingest configuration exists. Only if a Splunk configuration exist, the meta-data fieldhost
should be added or overwritten in the memory hold configuration. Only after that theLogger
object can be created by utilizing the in memory stored configuration.This should be already auto generated by the Guidance on project creation.
Workaround (implementation example)
Unfortunately this approach contains hard-coded JSON configuration paths as at point in time this was implemented we were in a rush and needed an implementation. Hence it would be awesome to determine those paths dynamically.
Please find the following workaround as code files in the attachements.
Within the
Startup.cs
Used extension methods from
ConfigurationExtensions.cs
Attachements
Workaround-serilog-sinks-splunk_host-field.zip