Hello,
I use UE_LOG for logging, but is there a way, that this logging is send to a Seq Server?
Kind Regards,
Bert Berrevoets.
Hello,
I use UE_LOG for logging, but is there a way, that this logging is send to a Seq Server?
Kind Regards,
Bert Berrevoets.
Just thinking out loud, but you might want to collect the log files with external software. Logging can be done to screen / output window / file. If you’d implement a way to log your own messages to another server you’d still be missing the log data implemented in the engine itself. I’d collect the files every now and then and keep the code as is.
Might find something of use here too:
I had found a tutorial, but i can not find it anymore
there they create the following class:
HeaderFile
#pragma once
#include "CoreMinimal.h"
#include "Logging/LogMacros.h"
#include "Logging/LogVerbosity.h"
#include "YourCustomLogSink.generated.h"
/**
* Custom logging sink class for sending log messages to Seq.
*/
UCLASS()
class YOURPROJECT_API UYourCustomLogSink : public UObject
{
GENERATED_BODY()
public:
/**
* Function to send log messages to Seq.
*
* @param InLogMessage The log message.
* @param InVerbosity The log verbosity level.
* @param InCategory The log category.
*/
void LogMessage(const TSharedPtr<struct FLogMessage>& InLogMessage, ELogVerbosity::Type InVerbosity, const FName& InCategory);
};
CPP File
#include "YourCustomLogSink.h"
#include "HttpModule.h" // You'll need this for making HTTP requests
void UYourCustomLogSink::LogMessage(const TSharedPtr<FLogMessage>& InLogMessage, ELogVerbosity::Type InVerbosity, const FName& InCategory)
{
// Extract log message text
FString LogText = InLogMessage->ToText();
// Customize this part to send the log message to your Seq server using HTTP or your preferred method
FString SeqServerURL = TEXT("http://your-seq-server-url-here");
FString SeqApiKey = TEXT("your-seq-api-key-here");
// Construct the HTTP request
TSharedRef<IHttpRequest, ESPMode::ThreadSafe> HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetVerb(TEXT("POST"));
HttpRequest->SetURL(SeqServerURL);
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
HttpRequest->SetHeader(TEXT("X-Seq-ApiKey"), SeqApiKey);
HttpRequest->SetContentAsString(LogText);
// Send the HTTP request
HttpRequest->ProcessRequest();
}
And to configure it in DefaultEngine.ini:
[/Script/Engine.Engine]
+ActiveLogSink="YourCustomLogSinkClass"
But the problem is in the line FString LogText = InLogMessage->ToText();
The editor say “InLogMessage: Type FLogMessage is incomplete.”
Can you help me with that error message?
Cool, wasn’t aware injection was an option. But UYourCustomLogSink inherits just from UObject?
Are you getting this when building in visual studio? If so you forgot to include the header file for FLogMessage or you forgot to add the module containing FLogMessage to your Build.cs file in your project source.
UE Documentation shows header / module info for all classes, but I only see your FLogMessage on GLTF plugin, no idea what that is:
https://docs.unrealengine.com/4.27/en-US/API/Plugins/GLTFCore/FLogMessage/