How to log in shipping build (Win)?

How do you enable logging so it logs in shipping?
I have some log console commands in blueprints but it doesn’t save any logs.

1 Like

Hey AchilleDepla-

The default for shipping builds is to not print out an logs for any platform, though it can be overridden to do so. USE_LOGGING_IN_SHIPPING needs to be defined. This can be enabled by enabling bUseLoggingInShipping in UBT.

Cheers

1 Like

Hi ,

Could you elaborate on where should we modify it? I’ve tried both modifying the xml in the engine’s Engine\Saved\UnrealBuildTool folder and setting bUseLoggingInShipping = true in the source code (UEBuildConfiguration.cs) - doesn’t seem to work. Normally the logs are in Saved/Logs folder, but that folder is not created in my packaged game’s folder after the play session. The “-log” parameter for the shortcut also doesn’t do anything.

Hey CodeSpartan-

You can find the setting for USE_LOGGING_IN_SHIPPING in the Source/Runtime/Core/Public/Misc/Build.h file. Changing the define here should allow you to get logging information in a shipping build.

Oh god dont tell me you have to actually rebuild the engine to turn this on??

3 Likes

Since this is a change to an engine source file, you would need to use a source version of the editor (the binary version from the launcher would not allow you to edit the file). Since a change to a source file is being made, you would need to compile after making the change. Since this is a single line being changed, the compile time should not be as long as an initial compile of the entire engine.

1 Like

Just for the record, I set that flag to 1 in the aforementioned H file and spend all day getting this engine to compile and run with my project and create a packed shipping version of my project and NADA! Zip, Zilch.
No logfile is created.

Seriously this is an ESSENTIAL feature. How else do you expect us to find errors on a client’s machine when there is no logfile? What were your people thinking when they decided that logfiles are useless as a tool to find errors?

4 Likes

I am experiencing this issue as well. I set USE_LOGGING_IN_SHIPPING to 1, then rebuild a huge part of the engine, but when I run the standalone shipping game there is no log file. Could this be a bug or is there something else that we need to set up?

Thanks,

Franco

I finally got it going based on this thread.
NOTE THE LAST PASSAGE IN THAT POST:

: Good thing to know for
future Googlers, for shipping builds,
save games and log files go in
C:\Users\UserName\AppData\Local\GameName

The logfile will not go in your game directory, but into this fixed location!

1 Like

So I am just reporting this here in order to make it a more complete answer. Generally changing the UEBuildConfiguration.cs or USE_LOGGING_IN_SHIPPING directly in engine is less than the desired usage. Though it may be changing things for the better in one case it is better to set variables in your target files like so:

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

Everything before your post is a chronicle of people not finding the solution. Your post is the solution. You should put it in a separate answer and it should be marked as correct. All I can do is up-vote your post.

Hi, did you get this to work? I have tried adding this to my games target file and it still doesn’t use logging in shipping.

You have to change this in the UE4Game.Target.cs (or Client/Editor/Server or all depending on your needs) in the UE4 engine source code.
You need to build the engine from source with these options for the engine to support logging in the shipping build.

With 4.18, you can just add “bUseLoggingInShipping = true;” to the TargetRules constructor in your Target.cs file.

1 Like

do i need to add this in my “MyGame”.Target.cs ?and is this possible for the engine from the launcher or only for source builds of the engine?

Thanks in advance,

Yes and I think it should but I use the source-built engine so I can’t say I’ve tried it.

Update: I was a bit mistaken. The answer above was updated to the correct flag to set. I originally said it was Target.bUseLoggingInShipping but it’s in the TargetRules, not the TargetInfo. I’m building something now to make sure it works but it will be a while (full rebuild) so I thought I’d get this correction up now.

Ya. It works. Doesn’t seem to show my PrintString calls though. Just the C++ log calls.

Additionally, with the new *.Target.cs option (see my answer), it still forces a full rebuild. Even if I only change MyServer.Target.cs, it causes the client to be rebuilt from scratch.

Also, I have noticed that this option only lets the UE_LOG messages through. BP “PrintString” nodes are not displayed. Personally, I call that a bug – or maybe a missing feature (another option we can set in TargetRules). The work-around is to expose a C++ function to BPs so they can call into it and perform a UE_LOG, but it should be easier IMO.

@ this fight between shipping and development is always an issue but I totally understand why hoops need to be jumped through. Debugging information embedded in print statements generates massive binaries and needs to be removed from the binaries. Every AAA project I’ve worked on has always had this issue. Perhaps one day we’ll be at a point where machines and download/load speeds are so powerful that we just don’t care but it seems likely that for a long time yet a project that takes care to remove this data will significantly out perform a project that doesn’t.

On rebuild step 16/1445 here so I feel your frustration!