Setting BuildSettings flags in 4.17

I need to set bUseLoggingInShipping = true so that I can get a log file to diagnose a problem in my shipping build.

In 4.15 the advice to enable log files was to add the following line to the project’s Build.cs:

UEBuildConfiguration.bUseLoggingInShipping = true;

However after 4.16 the TargetRules object that’s passed in is now ReadOnlyTargetRules so these flags can’t be set here (Unless there’s a workaround?). See This Answer for further details


So in addition to this I’ve found two other methods that I can’t get to work. The first is to modify the BuildConfiguration.xml which apparently worked in 4.16 but now it doesn’t in 4.17. Visual Studio immediately spits out a compiler error.

The Second method seems more likely to be the supported method, editing Engine.ini files to include the following lines:

[/Script/BuildSettings.BuildSettings]

bUseLoggingInShipping=True


I’ve tried adding these lines to

/4.17/Engine/Config/Windows/WindowsEngine.ini

/4.17/Engine/Config/BaseEngine.ini

/4.17/Engine/Config/BaseGame.ini

/Game/Config/DefaultEngine.ini

/Game/Config/DefaultGame.ini

However none of these attempts produced a log file at %AppData%/Local/MyGame/Saved/ It’s successfully writing SaveGames, CrashReports, and ini files to that directory though.

I’m at the end of my googling abilities and need some ideas on what to try next. Also since this has changed twice in the last two updates I imagine these things are going to continue to change in the next few versions, so if anyone could shed any light on where the devs are headed with this it would be helpful.

ReadOnlyTargetRules is passed into your module in the module’s build.cs, but you should be able to override the function SetupGlobalEnvironment in your target file like so.

public override void SetupGlobalEnvironment(TargetInfo Target, ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration, ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration )
{
UEBuildConfiguration.bUseLoggingInShipping = true;
// OR
OutCPPEnvironmentConfiguration.Definitions.Add("USE_LOGGING_IN_SHIPPING=1");
}

I just played with this a bit and it looks like you can get away with just setting

 UEBuildConfiguration.bUseLoggingInShipping = true;

the emitted file will be found in AppData\Local\(YourGameTitle)\Saved\Logs