Skip to content

Support dynamic loading serverUrl/token from on runtime #62

@akivamu

Description

@akivamu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions