Log Temp

A lot of the time you just need a quick output, LogTemp is useful for this

0
    UE_LOG(LogTemp, Warning, TEXT("Hi, I will apear in the output window"));

Log Variables

 0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
	FString MyString;
	UE_LOG(LogTemp, Warning, TEXT("The string value is %s"), *FString MyString;);

    int32 MyInteger;
    UE_LOG(LogTemp, Warning, TEXT("The integer value is: %d"), MyInteger);

    float MyFloat;
    UE_LOG(LogTemp, Warning, TEXT("The float value is: %f"), MyFloat);

    FVector MyVector;
    UE_LOG(LogTemp, Warning, TEXT("The vector value is: %s"), *MyVector.ToString());

    UE_LOG(LogTemp, Warning, TEXT("Current values are: vector %s, float %f, and integer %d"), *YourVector.ToString(), YourFloat, YourInteger);

Define your own category

Isolating your logs into a category can be super useful when working on specific features.

0
1
2
3
4
5
6
7
    /** 
	 * A macro to declare a logging category as a C++ "extern", usually declared in the header and paired with DEFINE_LOG_CATEGORY in the source. 
	 * Accessible by all files that include the header.
	 * @param CategoryName, category to declare
	 * @param DefaultVerbosity, default run time verbosity
	 * @param CompileTimeVerbosity, maximum verbosity to compile into the code
	 **/
    DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity);

Example

 0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    // In .h file
    ...
    DECLARE_LOG_CATEGORY_EXTERN(MyLogCategory, Log, All);
    ...

    // In .cpp file
    ...
    DEFINE_LOG_CATEGORY(MyLogCategory);
    ...

    // Throughout the code
    ...
    UE_LOG(MyLogCategory, Warning, TEXT("Hi, I will apear in the custom category"));

Verbose

In your projects DefaultEngine.ini set can change the verbosity by changing the following:

[Core.Log]
LogStreaming=Log
[Core.Log]
LogStreaming=Verbose
[Core.Log]
LogStreaming=VeryVerbose

Onscreen Messages

0
1
    if (GEngine)
        GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, [Your String Here]);
0
1
	if(GEngine)
	     GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Some yellow text on screen"));
0
1
	if(GEngine)
	     GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("Example text that prints a float: %f"), [My Float Variable]));

Blueprint Logging

Graph provided by DevBastian Check out his youtube channel here