Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/platforms/unreal/migration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@ We recommend using this guide starting from the version closes to your current v

### Breaking changes

#### Crash Backend Selection

The `UseNativeBackend` option is replaced by the `CrashBackend` option (**Project Settings > Plugins > Sentry > Crash Handling > Crash backend**), and the native backend is now the default on Windows, Linux, and Xbox. `CrashBackend` accepts the following values:

| Platform | `Auto` (default) | `Native` | `Legacy` |
| -------------- | ---------------- | -------- | ----------------------------- |
| Windows, Linux | Native | Native | Crashpad |
| Xbox | Native | Native | Breakpad |
| macOS | sentry-cocoa | Native | sentry-cocoa (same as `Auto`) |

The SDK no longer reads `UseNativeBackend`. If your project configuration file sets it, replace it with `CrashBackend`:

```ini
; Enabling the native backend before v2.0.0

[/Script/Sentry.SentrySettings]
UseNativeBackend=True

; Enabling the native backend in v2.0.0 (also on macOS)

[/Script/Sentry.SentrySettings]
CrashBackend=Native
```

If you want to keep using Crashpad on Windows and Linux or Breakpad on Xbox, set `CrashBackend=Legacy`.

The backend is selected at build time, so rebuild your project after changing this option.

#### Assert Handling

`FSentryOutputDevice` and `FSentryErrorOutputDevice` are no longer part of the public API. If you subscribed to the `OnAssert` delegate of `FSentryErrorOutputDevice`, use the static `FSentryDelegates::OnAssert` delegate instead:
Expand Down Expand Up @@ -40,6 +68,38 @@ FSentryDelegates::OnAssert.AddLambda([](const FString& Message)

The delegate is called on the thread that hit the assertion, before the crash is reported. Your handler must be thread-safe and must not access UObjects.

#### Structured Logs Level

Structured logs now use the new `ESentryLogLevel` enum instead of `ESentryLevel`. It adds the `Trace` level, which the logs protocol supports but events, breadcrumbs, and scopes don't. Events, breadcrumbs, and scopes still use `ESentryLevel`.

If you set or read the level of a `USentryLog` (for example, in a custom `USentryBeforeLogHandler`), update your code to use `ESentryLogLevel`:

```cpp
// Filtering logs by level before v2.0.0

if (LogData->GetLevel() == ESentryLevel::Debug)
{
return nullptr;
}

// Filtering logs by level in v2.0.0

if (LogData->GetLevel() == ESentryLogLevel::Debug || LogData->GetLevel() == ESentryLogLevel::Trace)
{
return nullptr;
}
```

If you use Blueprints, recreate the **Set Level** and **Get Level** nodes of `Sentry Log` objects and the nodes connected to them.

#### Unreal Engine Log Forwarding

`UE_LOG` messages with `VeryVerbose` verbosity are now sent as `trace` structured logs instead of `debug` ones. The `Verbose/VeryVerbose` option in the plugin settings (`StructuredLoggingLevels.bOnDebugLog`) is split into the `Verbose` (`bOnDebugLog`) and `VeryVerbose` (`bOnTraceLog`) options.

The `VeryVerbose` option is disabled by default. If your project forwards `Verbose` messages and you also want to forward `VeryVerbose` messages, enable `bOnTraceLog`.

Breadcrumbs for `VeryVerbose` messages still use the `Debug` level.

## Migrating to 1.0.0

### Breaking changes
Expand Down
31 changes: 14 additions & 17 deletions platform-includes/logs/best-practices/unreal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ This makes debugging dramatically faster — one query returns everything about

```cpp
// ❌ Scattered thin logs
SentrySubsystem->AddLog(TEXT("Starting checkout"), ESentryLevel::Info);
SentrySubsystem->AddLog(TEXT("Validating cart"), ESentryLevel::Info);
SentrySubsystem->AddLog(TEXT("Processing payment"), ESentryLevel::Info);
SentrySubsystem->AddLog(TEXT("Checkout complete"), ESentryLevel::Info);
SentrySubsystem->LogInfo(TEXT("Starting checkout"));
SentrySubsystem->LogInfo(TEXT("Validating cart"));
SentrySubsystem->LogInfo(TEXT("Processing payment"));
SentrySubsystem->LogInfo(TEXT("Checkout complete"));

// ✅ One wide event with full context
// Use categories and descriptive messages
SentrySubsystem->AddLog(
SentrySubsystem->LogInfo(
FString::Printf(TEXT("Checkout completed - Order: %s, User: %s, Value: %.2f"),
*OrderId, *UserId, CartValue),
ESentryLevel::Info,
TEXT("Checkout")
);
```
Expand All @@ -34,17 +33,15 @@ Use categories to organize logs and make them easier to search and filter.

```cpp
// Use categories for different systems
SentrySubsystem->AddLog(
SentrySubsystem->LogInfo(
FString::Printf(TEXT("Purchase completed - User: %s, Tier: %s, Value: %.2f"),
*UserId, *UserTier, PurchaseValue),
ESentryLevel::Info,
TEXT("IAP")
);

SentrySubsystem->AddLog(
SentrySubsystem->LogInfo(
FString::Printf(TEXT("Level loaded - Name: %s, LoadTime: %.2fs"),
*LevelName, LoadTime),
ESentryLevel::Info,
TEXT("GameFlow")
);
```
Expand All @@ -57,13 +54,13 @@ Pick a naming convention and stick with it across your codebase. Inconsistent na

```cpp
// ❌ Inconsistent categories
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("player"));
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("Player"));
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("PLAYER"));
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("PlayerSystem"));
SentrySubsystem->LogInfo(TEXT("..."), TEXT("player"));
SentrySubsystem->LogInfo(TEXT("..."), TEXT("Player"));
SentrySubsystem->LogInfo(TEXT("..."), TEXT("PLAYER"));
SentrySubsystem->LogInfo(TEXT("..."), TEXT("PlayerSystem"));

// ✅ Consistent PascalCase categories
SentrySubsystem->AddLog(TEXT("Player spawned"), ESentryLevel::Info, TEXT("Player"));
SentrySubsystem->AddLog(TEXT("Player died"), ESentryLevel::Warning, TEXT("Player"));
SentrySubsystem->AddLog(TEXT("Player score updated"), ESentryLevel::Debug, TEXT("Player"));
SentrySubsystem->LogInfo(TEXT("Player spawned"), TEXT("Player"));
SentrySubsystem->LogWarning(TEXT("Player died"), TEXT("Player"));
SentrySubsystem->LogDebug(TEXT("Player score updated"), TEXT("Player"));
```
11 changes: 6 additions & 5 deletions platform-includes/logs/options/unreal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ The following configuration options are available for Sentry Logs in Unreal Engi

| Option | Description | Default |
|--------|-------------|------------|
| **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 | `false` |
| **Enable Error Logs** | Forward Error level UE_LOG calls to Sentry | `false` |
| **Enable Fatal Logs** | Forward Fatal level UE_LOG calls to Sentry | `false` |
| **VeryVerbose** | Forward VeryVerbose UE_LOG calls to Sentry as Trace level logs | `false` |
| **Verbose** | Forward Verbose UE_LOG calls to Sentry as Debug level logs | `false` |
| **Display/Log** | Forward Display and Log UE_LOG calls to Sentry as Info level logs | `false` |
| **Warning** | Forward Warning UE_LOG calls to Sentry as Warning level logs | `false` |
| **Error** | Forward Error UE_LOG calls to Sentry as Error level logs | `false` |
| **Fatal** | Forward Fatal UE_LOG calls to Sentry as Fatal level logs | `false` |
| **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 |
21 changes: 17 additions & 4 deletions platform-includes/logs/setup/unreal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem
SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
{
// Enable specific severity levels for UE_LOG forwarding
Settings->StructuredLoggingLevels.bOnTraceLog = false;
Settings->StructuredLoggingLevels.bOnDebugLog = false;
Settings->StructuredLoggingLevels.bOnInfoLog = true;
Settings->StructuredLoggingLevels.bOnWarningLog = true;
Expand All @@ -25,6 +26,17 @@ SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::Create
}));
```

The SDK maps `UE_LOG` verbosity to structured log levels as follows:

| `UE_LOG` verbosity | Setting | Sentry Logs UI Severity |
| --- | --- | --- |
| `Fatal` | `bOnFatalLog` | FATAL |
| `Error` | `bOnErrorLog` | ERROR |
| `Warning` | `bOnWarningLog` | WARN |
| `Display`, `Log` | `bOnInfoLog` | INFO |
| `Verbose` | `bOnDebugLog` | DEBUG |
| `VeryVerbose` | `bOnTraceLog` | TRACE |

#### Log Category Filtering

You can filter which log categories are sent to Sentry:
Expand Down Expand Up @@ -63,8 +75,8 @@ class UCustomLogFilter : public USentryBeforeLogHandler
public:
virtual USentryLog* HandleBeforeLog_Implementation(USentryLog* LogData) override
{
// Filter out all debug logs
if (LogData->GetLevel() == ESentryLevel::Debug)
// Filter out all trace and debug logs
if (LogData->GetLevel() == ESentryLogLevel::Trace || LogData->GetLevel() == ESentryLogLevel::Debug)
{
return nullptr; // Return null to prevent sending
}
Expand Down Expand Up @@ -93,6 +105,7 @@ SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);
void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
{
// Configure individual severity levels
Settings->StructuredLoggingLevels.bOnTraceLog = false;
Settings->StructuredLoggingLevels.bOnDebugLog = false;
Settings->StructuredLoggingLevels.bOnInfoLog = true;
Settings->StructuredLoggingLevels.bOnWarningLog = true;
Expand All @@ -111,9 +124,9 @@ 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`)
- `GetLevel()`: Returns the severity level of the log (`ESentryLogLevel`)
- `GetBody()`: Returns the formatted log message (`FString`)
- `SetLevel(ESentryLevel Level)`: Sets the Level of the Log Event
- `SetLevel(ESentryLogLevel 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
Expand Down
6 changes: 5 additions & 1 deletion platform-includes/logs/usage/unreal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SentrySubsystem->LogWarningWithAttributes(
```

Each log level has a corresponding method with attributes support:
- `LogTraceWithAttributes()`
- `LogDebugWithAttributes()`
- `LogInfoWithAttributes()`
- `LogWarningWithAttributes()`
Expand Down Expand Up @@ -77,6 +78,7 @@ Sentry Logs supports the following log levels:

| Method | Sentry Logs UI Severity |
| --- | --- |
| `LogTrace()` | TRACE |
| `LogDebug()` | DEBUG |
| `LogInfo()` | INFO |
| `LogWarning()` | WARN |
Expand All @@ -85,6 +87,7 @@ Sentry Logs supports the following log levels:

```cpp
// Examples of different log levels
SentrySubsystem->LogTrace(TEXT("Inventory update started"), TEXT("Inventory"));
SentrySubsystem->LogDebug(TEXT("Player position updated"), TEXT("Player"));
SentrySubsystem->LogInfo(TEXT("Level loaded successfully"), TEXT("GameFlow"));
SentrySubsystem->LogWarning(TEXT("Low memory warning"), TEXT("Performance"));
Expand All @@ -100,7 +103,8 @@ When structured logging is enabled with the appropriate severity levels, the SDK
// 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
UE_LOG(LogTemp, Log, TEXT("Debug information")); // Only sent if StructuredLoggingLevels.bOnInfoLog = true
UE_LOG(LogTemp, VeryVerbose, TEXT("Trace information")); // Sent as a trace log if StructuredLoggingLevels.bOnTraceLog = true
```

You can configure whether these logs are sent as:
Expand Down
Loading