When does the log start up?

I might be using AGameInfo completely wrong, so please feel free to correct me if that’s the issue. In my GameInfo subclass, AMyProjectGameInfo, I have the following code:

void AMyProjectGameInfo::PreInitializeComponents()
	UE_LOG(Sagittarius, Log, TEXT("HELLO WORLD!!"));
	ASagittarius* sag = GetWorld()->SpawnActor();

I have added DEFINE_LOG_CATEGORY(Sagittarius); in MyProject.cpp and DECLARE_LOG_CATEGORY_EXTERN(Sagittarius, Log, Log); in MyProject.h, everything compiles fine, so it should work. This should not only print the line HELLO WORLD!, but some underlying log strings that the Encrypt() function calls.

I was under the impression that PreInitializeComponents() and PostInitializeComponents() are analogous to PreBeginPlay() and PostBeginPlay() from UDK, so the log should already be open at this time. However, nothing gets printed.

I also tried logging from InitGame() and PostLogin(), nothing there either. I didn’t expect there to be any output from InitGame() since that is likely before the logging system gets initialized.

So what is the problem? And when is the earliest time that we can use the logging system?

EDIT: The relevant portion from my log is:

[0002.61] LogWorld: Game class is 'MyProjectGameInfo'
[0002.62] LogWorld: Bringing World /Temp/Autosaves//Game/UEDPCLaserMap.TheWorld up for play (0) at 2013.10.11-13.46.10
[0002.62] LogWorld: Bringing up level for play took: 0.002030
[0002.62] LogPlayerController: ClientRestart_Implementation DefaultPawn_0
[0002.62] LogPlayerController: ServerAcknowledgePossession_Implementation DefaultPawn_0
[0002.62] LogLoad:  Loading URL /Temp/Autosaves//Game/UEDPCLaserMap?Name=Player: 0.10 seconds
[0002.62] LogInit:Display: Game Engine Initialized.
[0002.62] LogLoad: UGameEngine::Init: 0.96 seconds
[0002.62] LogLoad: Full Startup: 2.62 seconds
[0002.64] LogAssetRegistry: FAssetRegistry took 0.000000 seconds to start up
[0002.69] LogRenderer:Warning: Reallocating scene render targets to support 1280x720.
[0013.36] LogEngine: All Windows Closed
[0013.36] LogWindows: FPlatformMisc::RequestExit(0)
[0014.52] LogHttp: Start Http request. url=https://api.swrve.com/1/session_end?api_key=TWn7EDcoV0xHSxGhYwCd&user=c5f5b374a77b3fd3a5107d152c6d0dc1&app_version=
[0014.52] LogHttp: Start Http request. url=http://udkprofiler.epicgames.com/ETAP/SendEvent.1?SessionID={31246674-4F18-7CA8-53A0-82BD39C4A1FE}&AppID=Rocket.Release&AppVersion=
[0014.52] LogExit: Preparing to exit.
[0014.54] LogExit: Game engine shut down

I can also confirm that if you overwrite the gameengine class, logging does not appear to be working there either.

I think the log system actually caches log items that are printed before it is ready, so you should be able to log anything at any time, but perhaps not before main starts.

Maybe it is suppressed, try these:

UE_LOG(LogTemp, Warning, TEXT("Warning"));
UE_LOG(LogTemp, Error, TEXT("Error"));
UE_LOG(LogTemp, Fatal, TEXT("Fatal"));

Could be some issue with modules or something…but LogTemp should always work…so we can start there.

Thank you for the response! But it still does not work. I have updated my question with the relevant part of the log, hopefully that gives some more clues as to the problem.

Logging suddenly started working for no particular reason. The last however many builds it was not, now it just is, even though I’m sure I didn’t change any code related to my log functions. Anyway thanks again for the help!

I noticed that some parts of the log only show up in the actual file, not in the console version.

Have you checked your Saved/Logs and your most recent log to see if it is getting printed there?



The excerpt above is from the actual file :-/ I actually usually don’t run console, do you think it’s possible that some things get printed to console that don’t also get written to log?