bPublicLogFiles

bPublicLogFiles

#Overview

name: bPublicLogFiles

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files. Also referenced in 1 C# build file meaning it may affect the build system logic.

#Summary

#Usage in the C++ source code

The purpose of bPublicLogFiles is to control the accessibility of log files in Android applications built with Unreal Engine 5. It determines whether the log files should be made publicly accessible or kept private within the application’s storage.

This setting variable is primarily used in the Android-specific subsystem of Unreal Engine, particularly in the Android runtime settings and the Java Native Interface (JNI) implementation.

The value of this variable is set in the Android Runtime Settings, which can be configured in the Unreal Engine editor. It is defined as a UPROPERTY in the UAndroidRuntimeSettings class, making it editable through the editor interface.

bPublicLogFiles interacts with other variables and systems:

  1. It is used in conjunction with bUseExternalFilesDir to determine the file path for logs.
  2. It affects the GOverrideAndroidLogDir global variable in shipping builds.

Developers must be aware of the following when using this variable:

  1. Setting this to true may require the WRITE_EXTERNAL_STORAGE permission for Android API 23+.
  2. It only affects shipping builds; in non-shipping builds, logs are always stored in the external file path.
  3. This setting has security implications, as it determines whether log files are publicly accessible.

Best practices when using this variable include:

  1. Consider the security implications of making log files public. Only enable this if absolutely necessary.
  2. Ensure that sensitive information is not logged when this setting is enabled.
  3. Be aware of the Android permissions required when changing this setting.
  4. Test the application thoroughly in both public and private log file configurations to ensure proper functionality.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:3048, section: [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:273

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:

	// You may require WRITE_EXTERNAL_STORAGE permission if you do not use ExternalFilesDir checkbox in android api 23+
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "APK Packaging", Meta = (DisplayName = "Make log files always publicly accessible?"))
	bool bPublicLogFiles;

	// The permitted orientation of the application on the device
	UPROPERTY(GlobalConfig, EditAnywhere, Category = "APK Packaging")
	TEnumAsByte<EAndroidScreenOrientation::Type> Orientation;

	// Maximum supported aspect ratio (width / height). Android will automatically letterbox application on devices with bigger aspect ratio

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp:1792

Scope (from outer to inner):

file
function     JNI_METHOD void Java_com_epicgames_unreal_GameActivity_nativeSetGlobalActivity

Source code excerpt:


//This function is declared in the Java-defined class, GameActivity.java: "public native void nativeSetGlobalActivity();"
JNI_METHOD void Java_com_epicgames_unreal_GameActivity_nativeSetGlobalActivity(JNIEnv* jenv, jobject thiz, jboolean bUseExternalFilesDir, jboolean bPublicLogFiles, jstring internalFilePath, jstring externalFilePath, jboolean bOBBinAPK, jstring APKFilename /*, jobject googleServices*/)
{
	STANDALONE_DEBUG_LOG(TEXT("nativeSetGlobalActivity(unreal): Entering unreal nativeSetGlobalActivity, GameActivityThis=%p\n"), FJavaWrapper::GameActivityThis);
	if (FJavaWrapper::GameActivityThis != nullptr)
	{
		STANDALONE_DEBUG_LOG(TEXT("nativeSetGlobalActivity(unreal): Error GameActivityThis is already set GameActivityThis=%p\n"), FJavaWrapper::GameActivityThis);
		//jenv->DeleteGlobalRef(FJavaWrapper::GameActivityThis);

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp:1831

Scope (from outer to inner):

file
function     JNI_METHOD void Java_com_epicgames_unreal_GameActivity_nativeSetGlobalActivity

Source code excerpt:

#if UE_BUILD_SHIPPING
			GFilePathBase = GInternalFilePath;
			GOverrideAndroidLogDir = bPublicLogFiles;
#else
			GFilePathBase = GExternalFilePath;
#endif
			FPlatformMisc::LowLevelOutputDebugStringf(TEXT("nativeSetGlobalActivity(unreal): GFilePathBase Path override to'%s'\n"), *GFilePathBase);
		}

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp:2174

Scope (from outer to inner):

file
function     JNI_METHOD void Java_com_epicgames_makeaar_GameActivityForMakeAAR_nativeSetGlobalActivity

Source code excerpt:

}
#if USE_ANDROID_STANDALONE
JNI_METHOD void Java_com_epicgames_makeaar_GameActivityForMakeAAR_nativeSetGlobalActivity(JNIEnv* jenv, jobject thiz, jboolean bUseExternalFilesDir, jboolean bPublicLogFiles, jstring internalFilePath, jstring externalFilePath, jboolean bOBBinAPK, jstring APKFilename /*, jobject googleServices*/)
{
	STANDALONE_DEBUG_LOG(TEXT("nativeSetGlobalActivity: Entering makeaar nativeSetGlobalActivity, GameActivityThis=%p\n"), FJavaWrapper::GameActivityThis);
	if (FJavaWrapper::GameActivityThis != nullptr)
	{
		STANDALONE_DEBUG_LOG(TEXT("nativeSetGlobalActivity(makeaar): Error GameActivityThis is already set GameActivityThis=%p\n"), FJavaWrapper::GameActivityThis);
		//jenv->DeleteGlobalRef(FJavaWrapper::GameActivityThis);

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp:2210

Scope (from outer to inner):

file
function     JNI_METHOD void Java_com_epicgames_makeaar_GameActivityForMakeAAR_nativeSetGlobalActivity

Source code excerpt:

#if UE_BUILD_SHIPPING
			GFilePathBase = GInternalFilePath;
			GOverrideAndroidLogDir = bPublicLogFiles;
#else
			GFilePathBase = GExternalFilePath;
#endif
			FPlatformMisc::LowLevelOutputDebugStringf(TEXT("nativeSetGlobalActivity(makeaar): GFilePathBase Path override to'%s'\n"), *GFilePathBase);
		}
		FPlatformMisc::LowLevelOutputDebugStringf(TEXT("nativeSetGlobalActivity(makeaar): InternalFilePath found as '%s'\n"), *GInternalFilePath);

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp:2220

Scope (from outer to inner):

file
function     JNI_METHOD void Java_com_epicgames_makeaar_GameActivityForMakeAAR_nativeSetGlobalActivity

Source code excerpt:

	}
	// DO NOT CALL, we have already handled logic above...
	// Java_com_epicgames_unreal_GameActivity_nativeSetGlobalActivity(jenv, thiz, bUseExternalFilesDir, bPublicLogFiles, internalFilePath, externalFilePath, bOBBinAPK, APKFilename);
}
#endif // USE_ANDROID_STANDALONE

void FJavaWrapper::SetupEmbeddedCommunication(JNIEnv* Env)
{
#if BUILD_EMBEDDED_APP

#References in C# build files

This variable is referenced in the following C# build files:

Location: <Workspace>/Engine/Source/Programs/UnrealBuildTool/Platform/Android/UEDeployAndroid.cs:2669


			bool bPublicLogFiles = true;
			Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bPublicLogFiles", out bPublicLogFiles);
			if (!bUseExternalFilesDir)
			{
				bPublicLogFiles = false;
			}

			string InstallLocation;