Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dynamic loading serverUrl/token from on runtime #62

Open
akivamu opened this issue Dec 23, 2022 · 0 comments
Open

Support dynamic loading serverUrl/token from on runtime #62

akivamu opened this issue Dec 23, 2022 · 0 comments

Comments

@akivamu
Copy link

akivamu commented Dec 23, 2022

Use case

I have the nlog.config for target: serverUrl="${var:serverUrl}"
This var is set at runtime, on the code when ASPCore startup, e.g NLog.LogManager.Configuration.Variables["serverUrl"] = xxx
The same to other dynamic value mechanisms.

Problem

Error in internalLog:
Exception: NLog.NLogConfigurationException: SplunkHttpEventCollector ServerUrl is not set!

We're checking the ServerUrl in InitializeTarget().
At this time, that var is not available yet, because it is set later at runtime.
Hence, exception is thrown and _hecSender is not initialized.

Proposal

Create _hecSender when needed, not at InitializeTarget.

Reference implementation: https://github.com/NLog/NLog/blob/dev/src/NLog/Targets/MailTarget.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant