diff --git a/src/dotnet-publish-iis/WebConfigTransform.cs b/src/dotnet-publish-iis/WebConfigTransform.cs
index 40e5509acd..de3df0cebc 100644
--- a/src/dotnet-publish-iis/WebConfigTransform.cs
+++ b/src/dotnet-publish-iis/WebConfigTransform.cs
@@ -59,6 +59,7 @@ namespace Microsoft.AspNetCore.Tools.PublishIIS
{
httpPlatformElement.SetAttributeValue("processPath", Path.Combine("..", appName));
SetAttributeValueIfEmpty(httpPlatformElement, "stdoutLogEnabled", "false");
+ SetAttributeValueIfEmpty(httpPlatformElement, "stdoutLogFile", @"..\logs\stdout.log");
SetAttributeValueIfEmpty(httpPlatformElement, "startupTimeLimit", "3600");
}
diff --git a/test/dotnet-publish-iis.Tests/WebConfigTransformFacts.cs b/test/dotnet-publish-iis.Tests/WebConfigTransformFacts.cs
index e1aeddb3b0..d61a5f8623 100644
--- a/test/dotnet-publish-iis.Tests/WebConfigTransformFacts.cs
+++ b/test/dotnet-publish-iis.Tests/WebConfigTransformFacts.cs
@@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Tools.PublishIIS.Tests
-
+
");
@@ -96,6 +96,58 @@ namespace Microsoft.AspNetCore.Tools.PublishIIS.Tests
WebConfigTransform.Transform(input, "app.exe").Descendants("httpPlatform").Elements().Single()));
}
+ [Fact]
+ public void WebConfigTransform_adds_stdoutLogEnabled_if_attribute_is_missing()
+ {
+ var input = new XDocument(WebConfigTemplate);
+ input.Descendants("httpPlatform").Attributes("stdoutLogEnabled").Remove();
+
+ Assert.Equal(
+ "false",
+ (string)WebConfigTransform.Transform(input, "test.exe").Descendants().Attributes("stdoutLogEnabled").Single());
+ }
+
+ [Theory]
+ [InlineData(null)]
+ [InlineData("false")]
+ [InlineData("true")]
+ public void WebConfigTransform_adds_stdoutLogFile_if_attribute_is_missing(string stdoutLogFile)
+ {
+ var input = new XDocument(WebConfigTemplate);
+
+ var httpPlatformElement = input.Descendants("httpPlatform").Single();
+ httpPlatformElement.Attribute("stdoutLogEnabled").Remove();
+ if (stdoutLogFile != null)
+ {
+ httpPlatformElement.SetAttributeValue("stdoutLogEnabled", stdoutLogFile);
+ }
+
+ Assert.Equal(
+ @"..\logs\stdout.log",
+ (string)WebConfigTransform.Transform(input, "test.exe").Descendants().Attributes("stdoutLogFile").Single());
+ }
+
+ [Theory]
+ [InlineData(null)]
+ [InlineData("true")]
+ [InlineData("false")]
+ public void WebConfigTransform_does_not_change_existing_stdoutLogEnabled(string stdoutLogEnabledValue)
+ {
+ var input = new XDocument(WebConfigTemplate);
+ var httpPlatformElement = input.Descendants("httpPlatform").Single();
+
+ httpPlatformElement.SetAttributeValue("stdoutLogFile", "mylog.txt");
+ httpPlatformElement.Attributes("stdoutLogEnabled").Remove();
+ if (stdoutLogEnabledValue != null)
+ {
+ input.Descendants("httpPlatform").Single().SetAttributeValue("stdoutLogEnabled", stdoutLogEnabledValue);
+ }
+
+ Assert.Equal(
+ "mylog.txt",
+ (string)WebConfigTransform.Transform(input, "test.exe").Descendants().Attributes("stdoutLogFile").Single());
+ }
+
private bool VerifyMissingElementCreated(params string[] elementNames)
{
var input = new XDocument(WebConfigTemplate);