question

Markus Henschel avatar image
Markus Henschel asked

Playfab GSDK: UE4 Thunderhead Servers log file directory

We have a UE4 dedicated server running in the cloud with playfab with Thunderhead Servers. After being able to play on it the first time we wanted to get the server logs. The documentation says we should put our logs into the right directory and they will be fetched by playfab and made available for download.

The easiest and most straight forward way to let Unreal log into that directory would be to use the ABSLOG parameter. But how do we get the directory we are supposed to log into? The Playfab GSDK for cpp we use in the UE4 server seems to have code to get the right directory. It seems to check a command line variable and a json config file and uses whatever is availble.

Can the log folder in a could based environment with Thunderhead Servers really come from a json config file? Because if we could rely on the environment variable GSDK_LOG_FOLDER then we could just use it in a script to launch the dedicated server like this:

UEServer.exe ABSLOG=%GSDK_LOG_FOLDER%\Serverlog.txt

Will the above work reliably?

unrealCustom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Hi @Markus Henschel,

>>…But how do we get the directory we are supposed to log into?

You can use the getLogsDirectory() function to get the log directory:

std::string logFolder = Microsoft::Azure::Gaming::GSDK::getLogsDirectory();

This happens during runtime.

>>… Can the log folder in a could based environment with Thunderhead Servers really come from a json config file?...Will the above work reliably?

The log folder are indeed coming from the JSON file that the GSDK agent initialized, a sample config file would be like this: gsdkSampleConfigWindows.json, however, this configuration is already existed on the cloud based environment and there is no a predefined Environment variable for usage. Therefore, your way may not work since you don't know the exact log folder before the game server starts. Moreover, UE4 doesn’t support changing the log location at runtime and it looked like the log folder path was only available from the GSDK. Therefore, a possible workaround would be to create an output redirector to create a second log to log all future log messages to the right location when the server starts as the answer suggested:

FString ServerLogDirectory = <query the GSDK for GSDK::LOG_FOLDER_KEY>FString 

ServerLogPath = FPaths::Combine(ServerLogDirectory, TEXT("MyServerLog.log"));

FOutputDeviceRedirector::Get()->AddOutputDevice(new FOutputDeviceFile(*ServerLogPath));
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.