Message Log
The Message Log is a way to display logs to the user in editor and in the output log at the same time. The messages display in the Message Log can react to user interaction by integrating Links to...
The Message Log is a way to display logs to the user in editor and in the output log at the same time. The messages display in the Message Log can react to user interaction by integrating Links to Objects, Blueprints, Assets and more. These messages are displayed in the "Message Log" window available at Window \> Developer Tool \> Message Log and are organized in multiples categories. Useful for artists and Level designer to have quick feedback on the level configuration.
For ''Output Log'' logging with ''UE_LOG'' see Logging
This articles describe the way to use the Message Log system in order to display messages to the user in the editor.
Terms and Structure
The Message Log system rely mainly on the FMessageLog
class and the FMessageLogModule
module.
A message is an instance of a FTokenizedMessage
created and added in a Message Log category. This category is defined by the FMessageLog
instance used to create each message.
Messages could be included in a Page. After the declaration of a page, each following messages are included in it. Most of the time, a new pages means a cleaning of old messages and a starts of a new sequence of messages.
These messages and pages are displayed in the Message Log window in Log Listings. Each listing is associated with a log category and are declared with the FMessageLogModule
module. A listing can be configured to allow page selection, clearing, message filtering and more.
Logging with Message Log
In this section, you will discover how to use the Message Log in your code to display rich messages in the editor's Message Log window. To keep this section focused on logging we will make use of FText::FromString()
but you must use LOCTEXT()
in a production project.
Simple logging
All messages must be created from an instance of FMessageLog
. This instance is created by giving the contructor a single FName
containing the log category where you want to send your log message.
// You need the following include at the beginning of the file
// Logging/MessageLog.h contains the declaration of FMessageLog
#include "Logging/MessageLog.h"
//...
// All messages created with this instance will be flushed to the "Play in Editor" log category listing in the Message Log window
FMessageLog PIELogger = FMessageLog(FName("PIE"));
See "Editor Log Categories" for a full list of the available log categories or "Log Listing creation" to create your own listing
Now, you can send your messages to this category using the Info()
, Warning()
, PerformanceWarning()
, Error()
or CriticalError()
methods depending of the severity if the message. All these methods only takes a single FText
containing the content of the message to display.
CriticalError()
method is used for fatal errors and will crash your editor/game if used. Use it in case you can't allow your game to run with this error occured.
PIELogger.Info(FText::FromString("Informationnal message"));
PIELogger.Warning(FText::FromString("Warning message"));
PIELogger.PerformanceWarning(FText::FromString("Warning message about performace issue"));
PIELogger.Error(FText::FromString("Error message"));
You can also use the Message()
method and specify the severity of it with the EMessageSeverity::Type
enum.
PIELogger.Message(EMessageSeverity::Type::Warning, FText::FromString("Enum defined Warning message"));
Messages are stored inside the FMessageLog
but not flushed to the Message Log system before the instance destruction. You must destroy the instance to send all messages declared with it. It isn't recomanded to keep an instance of FMessageLog
too long, keep it simple, just create a new instance in the current scope when you need to log something ant let it be destroyed at the end of the scope.
Rich Logging
Explain how to do a tokenized logging using FTokenizedMessage
Log Listing creation
This section assumes that you know what is a Game Module and already have one configured with a module class.
You can create easily your own log listing in your Game Module. For next sections, we assume that your module is called MyModule
1. Import MessageLog module
In your MyModule.Build.cs
file (in the root directory of your module), you can add it in the PrivateIncludePathModuleNames
list :
// MyModule.Build.cs
namespace UnrealBuildTool.Rules
{
public class MyModule : ModuleRules
{
public MyModule(ReadOnlyTargetRules Target) : base(Target)
{
// ...
PrivateIncludePathModuleNames.AddRange(
new string[]
{
// ...
"MessageLog",
}
);
}
}
}
2. Save your Log Listing
In the class of the module definition, add these required dependencies:
// MyModule.cpp
// (it should be located in your Private directory)
#include "MessageLog/Public/MessageLogInitializationOptions.h"
#include "MessageLog/Public/MessageLogModule.h"
Then use the MessageLogModule
to create your Log Listing
// still in MyModule.cpp
// ...
void FMyModule::StartupModule()
{
// ...
// create a message log to use in my module
FMessageLogModule& MessageLogModule = FModuleManager::LoadModuleChecked<FMessageLogModule>("MessageLog");
FMessageLogInitializationOptions InitOptions;
InitOptions.bShowPages = true;
InitOptions.bAllowClear = true;
InitOptions.bShowFilters = true;
MessageLogModule.RegisterLogListing("MyModule", NSLOCTEXT("MyModule", "MyModuleLogLabel", "My Module"), InitOptions);
}
And don't forget to unregistered the message log when the module is shutdown:
void FMyModule::ShutdownModule()
{
// ...
if (FModuleManager::Get().IsModuleLoaded("MessageLog"))
{
// unregister message log
FMessageLogModule& MessageLogModule = FModuleManager::GetModuleChecked<FMessageLogModule>("MessageLog");
MessageLogModule.UnregisterLogListing("MyModule");
}
}
3. Use it
And here you go! You can use it everywhere in your module now:
FMessageLog(FName("MyModule")).Error(LOCTEXT("InvalidValue", "This is not a good value!"));
4. See it
Editor Log Categories
Below, the list of all Unreal Engine defined log categories and their associated listings in the editor window.
Log Category Log Listing Label Notes
AssetTools
Asset Tools
AutomationTestingLog
Automation Testing Log
LocalizationService
Localization Service
SourceControl
Source Control
AnimBlueprintLog
Anim Blueprint Log
UDNParser
UDN Parse Errors
Not shown in the Message Log window
BlueprintLog
Blueprint Log
BuildAndSubmitErrors
Build and Submit Errors
TranslationEditor
Translation Editor
EditorErrors
Editor Errors
LoadErrors
Load Errors
LightingResults
Lighting Results
A new page is created before and after each new lightning build
PackagingResults
Packaging Results
MapCheck
Map Check
AssetCheck
Asset Check
SlateStyleLog
Slate Style Log
PIE
Play In Editor
A new page is created before each Play in Editor session
AssetReimport
Asset Reimport
CompilerResultsLog
Compiler Log
A new page is created before each compilation
BlueprintCompiler
or
[Blueprint GUID]_[Blueprint Name]_CompilerResultsLog
BlueprintCompiler
A new category can be created for each blueprint compilation
Not shown in the Message Log window
This table was created based on a search of .RegisterLogListing(
in the editor's source code. Last update 10th June 2020.