jlavallet
jlavallet

Reputation: 1367

How do I replace part of a path in my web.config transform?

I am trying to perform a web.config transform in Visual Studio 2022 by modifying the web.Debug.config file.

Changing attributes on elements, removing elements and attributes, etc. is all very straightforward. But I've a read through this document and I've done some Google searching, and I cannot figure out a way to replace part of a path string in my web.config file.

Given that I have lots of NLog target elements is there an easy way to replace the root path in the fileName and archiveFileName attributes for each?

Here is where I am coming from:

    <target xsi:type="File" name="seedDataLogFile"
            fileName="C:/ProductionPath/Logs/seedDataCurrent.json"
            archiveFileName="C:/ProductionPath/Logs/SeedDataArchive/{#}.json"
            archiveEvery="Day" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd" maxArchiveFiles="60"
            concurrentWrites="true" keepFileOpen="false">

And here is where I want to go:

    <target xsi:type="File" name="seedDataLogFile"
            fileName="D:/DevelopmentPath/Logs/seedDataCurrent.json"
            archiveFileName="D:/DevelopmentPath/Logs/SeedDataArchive/{#}.json"
            archiveEvery="Day" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd" maxArchiveFiles="60"
            concurrentWrites="true" keepFileOpen="false">

Thanks for your help.

Upvotes: 1

Views: 71

Answers (0)

Related Questions