I'm using Octopus as part of our deployment for a .NET Core 3.1 Web API project.
log4net.config
exists in .\Utility\Logs
.
I'm trying to follow the pattern here: https://help.octopus.com/t/transformation-best-practice-log4net-config-or-any-non-web-app-config/9906/4
As I understand it, this consists of three parts:
Create Log4Net.DeploymentTransform.config
, with the variables in #{name}
format - this has been done.
Turn on the "Substitute variables in files" feature, and point at the Log4Net.DeploymentTransform.config
transformation file (variable replacement happens before transformation). That would result in the #{LogFileLocation}
variable being replaced with whatever value was set for your LogFileLocation
variable in the current scope.
This is done and is working.when my app is deployed, Log4Net.DeploymentTransform.config
is there as well and the variable has been successfully set in it.
You'd also turn on the configuration transforms feature, and fill out the additional transforms section in the configuration transforms feature to identify your transform file (e.g. Log4Net.DeploymentTransform.config
=> log4net.config
).
This is not working, the content of Log4Net.DeploymentTransform.config
is not being copied on top of log4net.config
, though they are in the same folder upon deployment.
Here is what I did in our "deploy step"
Which sure looks like what the article is saying to do.
What else should I check? Any idea why step 3 isn't occurring?
Your syntax looks correct for the files - have you checked to ensure that you have the xdt attributes set?
In the example forum post you shared, the log4net
and appender
elements are tagged with xmlns:xdt
, xdt:Transform
and xdt:Match
attributes that help the XDT layer determine how to transform the files.
A quick example - I created a Log4NetConfigTest
package with two files -
Utility/Logs/log4net.config
Utility/Logs/log4net.trasnform.config
I used the same sample code from the forum post as well.
Here's the set up for my package deployment configurations:
With that set up (and my LogFileLocation
project variable set), I was able to see the following in my task log for the deployment:
Deploying package: C:\Octopus\Files\Log4NetConfigTest@S1.0.0@20004C95A0E0094490814B5A365DDAD2.zip
Transforming 'C:\Octopus\Applications\Development\Log4NetConfigTest\1.0.0_1\Utility\Logs\log4net.config' using 'C:\Octopus\Applications\Development\Log4NetConfigTest\1.0.0_1\Utility\Logs\log4net.transform.config'.
No matching appSetting, applicationSetting, nor connectionString names were found in: C:\Octopus\Applications\Development\Log4NetConfigTest\1.0.0_1\Utility\Logs\log4net.config
The task log confirmed that Octopus did apply the transformations, and once deployed, I confirmed that my new test log location was present and correct in both the base configuration and the transformation file.