I'm still exploring, and tried to use a real simplistic "include file" and didn't have a problem. But just to be on the safe side I figured I'd ask the question.
My simple example had a regular NLog.config file with a set of targets and rules. I added into it an include pointing to a different config file, it too containing a target and rule.
When I ran my little sample application, it worked fine. It picked up the fact there was an additional target and rule and it looks like it just added into the collections it already had from the NLog.config.
Is that the expected result?
I was looking at using the include file to provide granuality (sp?) for each module and keeping them in separate config files. I understand I could do that within one big NLog.config file, but by breaking it out with the individual configs, each module and its developer would have control over their settings without effecting others.
Maybe that was the original intention, but I wanted to confirm that assumption on my part.
One additional question -- if NLog doesn't find the include file, it throws an exception. Is there a way to prevent that without having to change the code? Again, thinking that depending on what was happening, I could have a "base" NLog.config file that has an "include" for different modules. If I found I needed to debug a particular module, I could install the include file for it with its target and rule. Once any debugging wascompleted, delete the file.
Or maybe just overlay it with a blank config file? Which might get around the exception of not finding a file?
Yes, the targets and rules should merge correctly. To be exact, they are processed as if the contents of the included file have been inserted in the place of inclusion. The includes are processed top-down and the appropriate sections (<targets> and <rules> should appear to be merged in this order):