Download

UE_LOG vs GLog

UE_LOG supports log category, verbosity and formatting the text within the macro.
Downsides:

  • You have to set log category and verbosity and both are added always to the output.
  • You have to declare and define log category.

GLog->Log supports concatenating, pure output, no need to set log category or verbosity.
GLog->FormatLogLine supports log category, verbosity, however creates a “deprecated C4996” compiler warning.

GLog is in CoreGlobals.h



CORE_API FOutputDeviceRedirector* GetGlobalLogSingleton();
#define GLog GetGlobalLogSingleton()


UE_LOG is in LogMacros.h


#define UE_LOG(CategoryName, Verbosity, Format, ...) \

Which one is the preferred/more future proof logging method within Unreal Engine?

I personally use UE_LOG for years now. The category is no big deal and you can use LogTemp anyhow instead of making your own.

UE_LOG is the preferred method. It is used everywhere in the engine.

Same here UE_LOG with a custom macro that tell me where is called (filename, row number and function)



#define __FILENAME__ (wcsrchr(__FILEW__, '\\') ? wcsrchr(__FILEW__, '\\') + 1 : __FILEW__)

#define RH_LOG_GENERAL UE_LOG(RHLogGeneral, Warning, TEXT("%s - R%i - %s"), __FILENAME__, __LINE__, __FUNCTIONW__);


example call (very simple, of course)


RH_LOG_GENERAL;

result

here a version with one parameter (pn = parameter name, pv = parameter value)



#define RH_LOG_PARAM(pn, pv) UE_LOG(RHLogGeneral, Warning, TEXT("%s - R%i - %s - %s:%s"), __FILENAME__, __LINE__, __FUNCTIONW__, pn, pv);


example call



RH_LOG_PARAM(TEXT("Pawn"), *InstigatorPawn->GetName());


result

Is very simple but for my purpose it work well :slight_smile: