How can I log a variable inside a variable?

So, I get that in order to log a variable you need to use

*Variable->GetName() 

or something similiar inside UE_LOG.

However, how do I go another level deep? (Variable->Variable->GetName() )

UE_LOG(SoldierLog, All, TEXT("SoldierInfo's Primary = '%s'"),*SoldierInfo->PrimaryWeap->GetName() ) //Causes crash at execution

UE_LOG(SoldierLog, All, TEXT("SoldierInfo's Primary = '%s'"),SoldierInfo->PrimaryWeap->GetName() ) //Doesn't compile

UE_LOG(SoldierLog, All, TEXT("SoldierInfo's Primary = '%s'"),*SoldierInfo->*PrimaryWeap->GetName() ) //Doesn't compile

There is no problem in C++ to chain pointers together like that.

I would put a temporary string right before the log setting it to SoldierInfo->PrimaryWeap->GetName() and put a breakpoint on it to see if it is valid.

Check it’s type if it is valid, The GetName() is maybe then the problem. I don’t think FText works in log.

So I did some testing after what you suggested, and it seems that GetName() DOES work. However if the variable is MISSING/NULL the game crashes.

So what’s the point of LOGGING if it crashes if the variable is missing? I understand you can use if(SoldierInfo->PrimaryWeap) but if I’m testing things to see if they spawn at a proper time. I don’t want to have to have a bunch of if statements. Is this how it’s suppose to be?