2017-09-27 13 views
0

프로덕션을 위해 다른 데이터베이스를 지정해야하는 NLog.config가 있습니다. 지금은 this 도구를 사용하고 있습니다. 다음은 NLog.Config의 일부입니다.web config 이외의 파일 변환 요소 대체

<?xml version="1.0" encoding="utf-8"?> 
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <targets> 
    <target name="ExceptionLog" type="Database"> 
    <connectionString> 
     ---- Db Connection string for test------- 
    </connectionString> 

프로덕션 변환을 만들었지 만 파일을 변환 할 수 없습니다. 여기

우리는 속성보다는 전체 요소를 변경해야 내가

<?xml version="1.0"?> 
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 

    <parameters value="Db connection for prod" 
      xdt:Transform="Replace" xdt:Locator="XPath(targets/target/connectionString)" /> 
</configuration> 

을 것입니다.

답변

1

는 "nlog"XDT 네임 스페이스 별칭 추가에 성공 :

내가 여기있는 exceptionlogs 같은 "DebugLogs"에 대한 또 다른 대상이 있습니다
<?xml version="1.0"?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" 
       xmlns:nlog="http://www.nlog-project.org/schemas/NLog.xsd"> 

    <nlog:connectionString xdt:Transform="Replace" 
     xdt:Locator="XPath(/nlog:nlog/nlog:targets/nlog:target/nlog:connectionString)"> 
    ....put-connection-string-here.... 
    </nlog:connectionString> 

</configuration> 
+0

, 어떻게 내가 두 번째 문자열을 대체 할을 ?? – SJMan

+1

'XPath (/ nlog : nlog/nlog : targets/nlog : target [@ 이름 = 'ExceptionLog']/nlog : connectionString)'속성을 사용하여 대상을 지정하고 다른 "Replace"를 @name = DebugLogs로 추가하십시오 . – Gedrox