Config Transformation on NLog does not work

前端 未结 10 1722
悲&欢浪女
悲&欢浪女 2021-02-05 09:15

I have a web project (ASP.NET MVC 4 project) that has a number of configurations stored in Web.Config and in NLog.config files.

I have

10条回答
  •  余生分开走
    2021-02-05 09:51

    To solve this issue I had to:

    1) Avoid the use of nlog.config

    2) Create nlog section inside web.config and move the contents of nlog.config to web.config to be able the use the web.config transformation feature with one file. To further instructions please take a look at: NLog configuration instructions

    3) Remove xmlns attributes from the nlog node. There seems to be a bug that messes everything during the web.config transformation. You can safely remove the following nodes:

    xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    

    4) I couldn't find a way to transform just a single target under nlog/targets node. To change the connection string of my logger, I had to copy the whole xml node, using a xdt:Transform="Replace" on the parent node like the following:

    
    
    
    

提交回复
热议问题