Is there a way to put NLog.config information in my app.config file?

Is there a way to put NLog.config information inside my app.config file? That way, I can have one configuration file instead of two. It might look like this:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nlog" type="..." /> </configSections> <nlog> <targets>...</targets> <rules>...</rules> </nlog> </configuration> 

Please let me know if this is a duplicate.

+5
source share
1 answer

Of course, you can put the configuration in the app.config file.

You just need to use NLog.Config.ConfigSectionHandler , so you need to write

 <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> </configSections> <nlog> <targets>...</targets> <rules>...</rules> </nlog> </configuration> 

as described in the NLog documentation in the section Configuration File Format .

+10
source

Source: https://habr.com/ru/post/1206283/


All Articles