0

I have a nlog logger configured via nlog.config file. I have multiple targets defined in the config file. Is it possible that if nlog fails to find any target (for e.g. database due to network error), it can ignore that particular target and write to all other targets.

Currently, if it doesn't find any of the target, it just throws an exception and breaks the program. Is there way that I can check on the startup, if all targets are found or not and act accordingly.

Also is there any way that I can create the .config file dynamically if not found? The last solution will be manually writing with a XmlWriter class, but was wondering if nlog has something default for this.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Marshal
  • 6,551
  • 13
  • 55
  • 91

1 Answers1

0

If you don't want NLog to throw exceptions, add the throwExceptions attribute to your NLog.config file:

<nlog throwExceptions="false">
   ...
</nlog>

As for your second question, you can also configure NLog programatically, if that helps. Creating your own NLog.config file seems kind of devious.

Stijn
  • 1,970
  • 3
  • 27
  • 36