Open neotrow opened 2 weeks ago
NLog supports referencing configuration defined elsewhere, i.e. not as part of NLog configuration itself. See https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer#configuration-syntax.
I think with this you can still configure the GoogleStackdriver target on appsettings.json
, but as a standalone object, not as part of NLog configuration. Then on each of the appsettings.{environment}.json
that you want to use GoogleStackdriver you configure NLog targets referencing the object defined in appsettings.json
.
@neotrow were you able to try my approach from the previous comment?
Is your feature request related to a problem? Please describe. We use
appsettings.{environment}.json
to configure NLog. In the rootappsettings.json
we have a configured theGoogleStackdriver
target. In theappsettings.{environment}.json
we have configured the rules for NLog to write the logs to the correct places. Inappsettings.Development.json
we don't want to write to gcp stackdriver. But our code now throws an exception because there were no credentials configured during the initialisation phase.Describe the solution you'd like We would appreciate an
enable
parameter that would skip the whole initialzion and maybe throw an exception if you try to write to gcp stack driver if this is set to false. Or alternativley have askipCredentials
parameter.Describe alternatives you've considered Our alternative is to move the gcp stack driver target to the
appsettings.{environment}.json
instead of the rootappsettings.json
but this means we have it duplicated.