Config Transformation on NLog does not work

前端 未结 10 1723
悲&欢浪女
悲&欢浪女 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 10:05

    It appears that I am quite late on this, but I have found that it is necessary for the NLog.config file to have the following:

    
    
    ...
    ...
    
    

    And the NLogTransform.config file (or whatever name it may have) to have the following:

    
    
    ...
    ...
    
    

    Here is some sample code to test the NLog transformation:

    var tmpConfigFile = new FileInfo("C:\\NLogs\\NLog.config");
    var transformFile = new FileInfo("C:\\Transforms\\NLogTransform.config");
    
    if (transformFile.Exists) {
        var xmlTransformableDocument = new XmlTransformableDocument();
        xmlTransformableDocument.Load(tmpConfigFile.FullName);
        var xmlTransformation = new XmlTransformation(transformFile.FullName);
        xmlTransformation.Apply(xmlTransformableDocument);
        xmlTransformableDocument.Save(tmpConfigFile.FullName);
    }
    

提交回复
热议问题