---
title: "Logs"
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
url: https://docs.sentry.io/platforms/unreal/logs/
---

# Set Up Logs | Sentry for Unreal Engine

With Sentry Structured Logs, you can send text-based log information from your Unreal Engine applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.

## [Requirements](https://docs.sentry.io/platforms/unreal/logs.md#requirements)

Logs for Unreal Engine are supported in Sentry Unreal Engine SDK version `1.2.0` and above.

## [Setup](https://docs.sentry.io/platforms/unreal/logs.md#setup)

To enable logging in your Unreal Engine project, you need to configure the Sentry SDK with structured logging enabled.

### [Project Settings Configuration](https://docs.sentry.io/platforms/unreal/logs.md#project-settings-configuration)

1. Open your project settings: **Project Settings > Plugins > Sentry**
2. Check the **Enable Structured Logging** option

### [Programmatic Configuration](https://docs.sentry.io/platforms/unreal/logs.md#programmatic-configuration)

Alternatively, you can enable logging programmatically when initializing the SDK:

```cpp
#include "SentrySubsystem.h"

void ConfigureSentryWithLogs()
{
    USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

    // Create settings with logging enabled
    SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
    {
        Settings->EnableStructuredLogging = true;
    }));
}
```

### [Advanced Configuration Options](https://docs.sentry.io/platforms/unreal/logs.md#advanced-configuration-options)

The Sentry SDK provides you with some advanced options to configure the log capture.

#### [Automatic Unreal Engine Log Forwarding](https://docs.sentry.io/platforms/unreal/logs.md#automatic-unreal-engine-log-forwarding)

You can configure the SDK to automatically forward Unreal Engine's native `UE_LOG` calls to Sentry based on the enabled severity levels:

```cpp
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

// Configure automatic log forwarding programmatically
SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
{
    Settings->EnableStructuredLogging = true;

    // Enable specific severity levels for UE_LOG forwarding
    Settings->StructuredLoggingLevels.bOnDebugLog = false;
    Settings->StructuredLoggingLevels.bOnInfoLog = true;
    Settings->StructuredLoggingLevels.bOnWarningLog = true;
    Settings->StructuredLoggingLevels.bOnErrorLog = true;
    Settings->StructuredLoggingLevels.bOnFatalLog = true;

    Settings->bSendBreadcrumbsWithStructuredLogging = false; // Send as structured logs instead of breadcrumbs
}));
```

#### [Log Category Filtering](https://docs.sentry.io/platforms/unreal/logs.md#log-category-filtering)

You can filter which log categories are sent to Sentry:

```cpp
// Configure category filtering
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

// Create settings with logging enabled
SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
{
    Settings->EnableStructuredLogging = true;

    // Only forward logs from specific categories
    TArray<FString> AllowedCategories;
    AllowedCategories.Add(TEXT("LogGameFlow"));
    AllowedCategories.Add(TEXT("LogPlayerSystem"));
    AllowedCategories.Add(TEXT("LogSentrySdk"));
    Settings->StructuredLoggingCategories = AllowedCategories;

}));
```

#### [Before-Log Handler](https://docs.sentry.io/platforms/unreal/logs.md#before-log-handler)

To filter logs, or update them before they are sent to Sentry, you can create a custom before-log handler class.

Avoid logging additional messages (for example, via `UE_LOG`) inside the `BeforeLog` handler. The SDK prevents recursive calls by skipping reentrant invocations — the log will still be captured, but your custom handler won't be called for it.

```cpp
UCLASS()
class UCustomLogFilter : public USentryBeforeLogHandler
{
    GENERATED_BODY()
public:
    virtual USentryLog* HandleBeforeLog_Implementation(USentryLog* LogData) override
    {
        // Filter out all debug logs
        if (LogData->GetLevel() == ESentryLevel::Debug)
        {
            return nullptr; // Return null to prevent sending
        }

        // Filter out logs based on message content
        if (LogData->GetBody().Contains(TEXT("Sensitive")))
        {
            return nullptr; // Filter out sensitive logs
        }

        // Filter based on specific categories
        if (LogData->GetBody().Contains(TEXT("Password")) ||
            LogData->GetBody().Contains(TEXT("Token")))
        {
            return nullptr; // Filter out authentication-related logs
        }

        return LogData; // Return modified event
    }
};

// Configure settings using delegate
FConfigureSettingsDelegate SettingsDelegate;
SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);

void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
{
    // Enable structured logging
    Settings->EnableStructuredLogging = true;

    // Configure individual severity levels
    Settings->StructuredLoggingLevels.bOnDebugLog = false;
    Settings->StructuredLoggingLevels.bOnInfoLog = true;
    Settings->StructuredLoggingLevels.bOnWarningLog = true;
    Settings->StructuredLoggingLevels.bOnErrorLog = true;
    Settings->StructuredLoggingLevels.bOnFatalLog = true;

    // Set custom before-log handler
    Settings->BeforeLogHandler = UCustomLogFilter::StaticClass();
}

// Initialize with settings delegate
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
SentrySubsystem->InitializeWithSettings(SettingsDelegate);
```

The `HandleBeforeLog_Implementation` method receives a `USentryLog` object, and should return the log event if you want it to be sent to Sentry, or `nullptr` if you want to discard it.

The `USentryLog` object has the following methods:

* `GetLevel()`: Returns the severity level of the log (`ESentryLevel`)
* `GetBody()`: Returns the formatted log message (`FString`)
* `SetLevel(ESentryLevel Level)`: Sets the Level of the Log Event
* `SetBody(FString& Body)`: Sets the Body of the Log Event
* `SetAttribute(Key, Value)`: Sets a custom attribute on the log
* `GetAttribute(Key)`: Gets an attribute value
* `TryGetAttribute(Key, OutValue)`: Returns `true` if attribute exists
* `RemoveAttribute(Key)`: Removes an attribute
* `AddAttributes(AttributesMap)`: Adds multiple attributes at once

## [Usage](https://docs.sentry.io/platforms/unreal/logs.md#usage)

Once logging is enabled, you can send log messages to Sentry using the logging methods on the Sentry subsystem.

### [Basic Logging](https://docs.sentry.io/platforms/unreal/logs.md#basic-logging)

```cpp
#include "SentrySubsystem.h"

void SendLogs()
{
    USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

    // Send a simple log message
    SentrySubsystem->LogInfo(TEXT("User completed tutorial"));

    // Send a log message with category
    SentrySubsystem->LogWarning(TEXT("Failed to load texture asset"), TEXT("AssetLoading"));

    // Send an error log
    SentrySubsystem->LogError(TEXT("Database connection failed"), TEXT("Database"));
}
```

### [Logging with Attributes](https://docs.sentry.io/platforms/unreal/logs.md#logging-with-attributes)

You can attach structured attributes to your logs for better filtering and searchability:

```cpp
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

TMap<FString, FSentryVariant> Attributes;
Attributes.Add(TEXT("user_id"), FSentryVariant(TEXT("12345")));
Attributes.Add(TEXT("level"), FSentryVariant(42));
Attributes.Add(TEXT("score"), FSentryVariant(99.5f));
Attributes.Add(TEXT("is_premium"), FSentryVariant(true));

SentrySubsystem->LogWarningWithAttributes(
    TEXT("Player achieved high score"),
    Attributes,
    TEXT("LogGameplay")
);
```

Each log level has a corresponding method with attributes support:

* `LogDebugWithAttributes()`
* `LogInfoWithAttributes()`
* `LogWarningWithAttributes()`
* `LogErrorWithAttributes()`
* `LogFatalWithAttributes()`

Attributes support the following types: `bool`, `int32`, `float`, and `FString`.

If the variant used to set an attribute value is of Array or Map type, it will be implicitly converted to the corresponding JSON string.

### [Global Attributes](https://docs.sentry.io/platforms/unreal/logs.md#global-attributes)

You can set global attributes that will be automatically attached to all captured logs:

```cpp
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

// Set global attributes that will be included in all logs
SentrySubsystem->SetAttribute(TEXT("game_version"), FSentryVariant(TEXT("2.1.0")));
SentrySubsystem->SetAttribute(TEXT("platform"), FSentryVariant(TEXT("PC")));

// All subsequent logs will include these attributes
SentrySubsystem->LogInfo(TEXT("Game started")); // Includes game_version and platform

// Remove when no longer needed
SentrySubsystem->RemoveAttribute(TEXT("platform"));
```

Global log attributes are not currently supported on Android. The `SetAttribute` and `RemoveAttribute` methods will be no-ops on that platform.

### [Log Levels](https://docs.sentry.io/platforms/unreal/logs.md#log-levels)

Sentry Logs supports the following log levels:

| Method         | Sentry Logs UI Severity |
| -------------- | ----------------------- |
| `LogDebug()`   | DEBUG                   |
| `LogInfo()`    | INFO                    |
| `LogWarning()` | WARN                    |
| `LogError()`   | ERROR                   |
| `LogFatal()`   | FATAL                   |

```cpp
// Examples of different log levels
SentrySubsystem->LogDebug(TEXT("Player position updated"), TEXT("Player"));
SentrySubsystem->LogInfo(TEXT("Level loaded successfully"), TEXT("GameFlow"));
SentrySubsystem->LogWarning(TEXT("Low memory warning"), TEXT("Performance"));
SentrySubsystem->LogError(TEXT("Failed to save game data"), TEXT("SaveSystem"));
SentrySubsystem->LogFatal(TEXT("Critical system failure"), TEXT("System"));
```

### [Automatic UE\_LOG Integration](https://docs.sentry.io/platforms/unreal/logs.md#automatic-ue_log-integration)

When structured logging is enabled with the appropriate severity levels, the SDK can automatically capture Unreal Engine's native `UE_LOG` calls:

```cpp
// Standard Unreal Engine logging - automatically captured when severity levels are enabled
UE_LOG(LogGameFlow, Warning, TEXT("Player health is critically low: %d"), PlayerHealth);
UE_LOG(LogAssets, Error, TEXT("Failed to load texture: %s"), *TexturePath);
UE_LOG(LogTemp, Log, TEXT("Debug information")); // Only sent if EnableInfoLogs = true
```

You can configure whether these logs are sent as:

* **Structured Logs**: Full log entries with searchable attributes
* **Breadcrumbs**: Contextual information attached to errors (useful for debugging)

### [Blueprint Support](https://docs.sentry.io/platforms/unreal/logs.md#blueprint-support)

You can also use Sentry Logs from Blueprints by calling the logging functions:

1. Add a **Log Warning** (or other level) node to your Blueprint
2. Set the **Message** parameter to your log message
3. Optionally set a **Category** for better organization

For logs with attributes, use the **Log Warning With Attributes** (or other level) nodes.

## [Options](https://docs.sentry.io/platforms/unreal/logs.md#options)

The following configuration options are available for Sentry Logs in Unreal Engine:

| Option                        | Description                                                              | Default |
| ----------------------------- | ------------------------------------------------------------------------ | ------- |
| **Enable Structured Logging** | Master toggle for the structured logging feature                         | `false` |
| **Enable Debug Logs**         | Forward Debug level UE\_LOG calls to Sentry                              | `false` |
| **Enable Info Logs**          | Forward Info level UE\_LOG calls to Sentry                               | `false` |
| **Enable Warning Logs**       | Forward Warning level UE\_LOG calls to Sentry                            | `true`  |
| **Enable Error Logs**         | Forward Error level UE\_LOG calls to Sentry                              | `true`  |
| **Enable Fatal Logs**         | Forward Fatal level UE\_LOG calls to Sentry                              | `true`  |
| **Send Logs As Breadcrumbs**  | Send UE\_LOG calls BOTH as Logs and as Breadcrumbs, instead of just Logs | `false` |
| **Log Category Filter**       | Array of log categories to include (empty = all categories)              | Empty   |
| **Before Log Callback**       | Handler to modify or filter log events before sending                    | None    |

## [Default Attributes](https://docs.sentry.io/platforms/unreal/logs.md#default-attributes)

The Unreal Engine SDK automatically sets several default attributes on all log entries to provide context and improve debugging:

### [Core Attributes](https://docs.sentry.io/platforms/unreal/logs.md#core-attributes)

* `environment`: The environment set in the SDK if defined. This is sent from the SDK as `sentry.environment`.
* `release`: The release set in the SDK if defined. This is sent from the SDK as `sentry.release`.
* `sdk.name`: The name of the SDK that sent the log. This is sent from the SDK as `sentry.sdk.name`.
* `sdk.version`: The version of the SDK that sent the log. This is sent from the SDK as `sentry.sdk.version`.

### [User Attributes](https://docs.sentry.io/platforms/unreal/logs.md#user-attributes)

* `user.id`: The user ID. Maps to id in the User payload, which is set by default by the SDKs.

If user information is available in the current scope, the following attributes are added to the log:

* `user.name`: The username. Maps to username in the User payload.
* `user.email`: The email address. Maps to email in the User payload.

## [Performance Considerations](https://docs.sentry.io/platforms/unreal/logs.md#performance-considerations)

* Logs are sent asynchronously to avoid impacting game performance
* Consider disabling Debug level logs in production to avoid excessive log volume
* Each severity level can be individually controlled to fine-tune what gets sent to Sentry
* Use categories to organize logs and make them easier to search and filter
* Before-log handlers are executed synchronously, so keep processing lightweight
