Skip to content

Commit 9cbecbb

Browse files
authored
docs(unreal): Document trace level and ESentryLogLevel for structured logs (#20915)
## DESCRIBE YOUR PR The Unreal SDK adds a separate `ESentryLogLevel` enum for structured logs. It includes the `Trace` level, which `ESentryLevel` can't express because events, breadcrumbs, and scopes have no such level. This is a breaking change in v2.0.0. Updates the logs and migration pages: - Adds a "Migrating to 2.0.0" section to the migration guide. It explains the switch from `ESentryLevel` to `ESentryLogLevel` for `USentryLog`, and that `VeryVerbose` `UE_LOG` messages are now sent as `trace` logs controlled by the new `bOnTraceLog` option. It also states that the new option is disabled by default, so projects that forward `Verbose` messages have to enable it to forward `VeryVerbose` messages. - Adds `LogTrace()` and `LogTraceWithAttributes()` to the usage page and a `UE_LOG` example for `VeryVerbose` messages. - Adds a table that maps `UE_LOG` verbosity to settings and log severity on the setup page, and updates the before-log handler example and the `USentryLog` method list to use `ESentryLogLevel`. - Updates the level rows in the options table to match the setting names in the plugin settings, and adds the new `VeryVerbose` option. - Changes the best practices examples to use the public `LogInfo()`, `LogWarning()`, and `LogDebug()` methods. They used `AddLog()` with `ESentryLevel`, which isn't part of the public API. Not ready to merge until getsentry/sentry-unreal#1715 is released in Unreal SDK v2.0.0. ## Related Items - getsentry/sentry-unreal#1715 - getsentry/sentry-unreal#1625 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the due date. You can update this information later by editing the PR description. - [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD - [ ] Other deadline: YYYY-MM-DD - [x] No deadline: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've supplied a deadline. Thanks in advance for your help! ## PRE-MERGE CHECKLIST _Make sure you've checked the following before merging your changes:_ - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
1 parent 09a273b commit 9cbecbb

5 files changed

Lines changed: 102 additions & 27 deletions

File tree

‎docs/platforms/unreal/migration/index.mdx‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@ We recommend using this guide starting from the version closes to your current v
1313

1414
### Breaking changes
1515

16+
#### Crash Backend Selection
17+
18+
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:
19+
20+
| Platform | `Auto` (default) | `Native` | `Legacy` |
21+
| -------------- | ---------------- | -------- | ----------------------------- |
22+
| Windows, Linux | Native | Native | Crashpad |
23+
| Xbox | Native | Native | Breakpad |
24+
| macOS | sentry-cocoa | Native | sentry-cocoa (same as `Auto`) |
25+
26+
The SDK no longer reads `UseNativeBackend`. If your project configuration file sets it, replace it with `CrashBackend`:
27+
28+
```ini
29+
; Enabling the native backend before v2.0.0
30+
31+
[/Script/Sentry.SentrySettings]
32+
UseNativeBackend=True
33+
34+
; Enabling the native backend in v2.0.0 (also on macOS)
35+
36+
[/Script/Sentry.SentrySettings]
37+
CrashBackend=Native
38+
```
39+
40+
If you want to keep using Crashpad on Windows and Linux or Breakpad on Xbox, set `CrashBackend=Legacy`.
41+
42+
The backend is selected at build time, so rebuild your project after changing this option.
43+
1644
#### Assert Handling
1745

1846
`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:
@@ -40,6 +68,38 @@ FSentryDelegates::OnAssert.AddLambda([](const FString& Message)
4068

4169
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.
4270

71+
#### Structured Logs Level
72+
73+
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`.
74+
75+
If you set or read the level of a `USentryLog` (for example, in a custom `USentryBeforeLogHandler`), update your code to use `ESentryLogLevel`:
76+
77+
```cpp
78+
// Filtering logs by level before v2.0.0
79+
80+
if (LogData->GetLevel() == ESentryLevel::Debug)
81+
{
82+
return nullptr;
83+
}
84+
85+
// Filtering logs by level in v2.0.0
86+
87+
if (LogData->GetLevel() == ESentryLogLevel::Debug || LogData->GetLevel() == ESentryLogLevel::Trace)
88+
{
89+
return nullptr;
90+
}
91+
```
92+
93+
If you use Blueprints, recreate the **Set Level** and **Get Level** nodes of `Sentry Log` objects and the nodes connected to them.
94+
95+
#### Unreal Engine Log Forwarding
96+
97+
`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.
98+
99+
The `VeryVerbose` option is disabled by default. If your project forwards `Verbose` messages and you also want to forward `VeryVerbose` messages, enable `bOnTraceLog`.
100+
101+
Breadcrumbs for `VeryVerbose` messages still use the `Debug` level.
102+
43103
## Migrating to 1.0.0
44104

45105
### Breaking changes

‎platform-includes/logs/best-practices/unreal.mdx‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ This makes debugging dramatically faster — one query returns everything about
66

77
```cpp
88
// ❌ Scattered thin logs
9-
SentrySubsystem->AddLog(TEXT("Starting checkout"), ESentryLevel::Info);
10-
SentrySubsystem->AddLog(TEXT("Validating cart"), ESentryLevel::Info);
11-
SentrySubsystem->AddLog(TEXT("Processing payment"), ESentryLevel::Info);
12-
SentrySubsystem->AddLog(TEXT("Checkout complete"), ESentryLevel::Info);
9+
SentrySubsystem->LogInfo(TEXT("Starting checkout"));
10+
SentrySubsystem->LogInfo(TEXT("Validating cart"));
11+
SentrySubsystem->LogInfo(TEXT("Processing payment"));
12+
SentrySubsystem->LogInfo(TEXT("Checkout complete"));
1313

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

3534
```cpp
3635
// Use categories for different systems
37-
SentrySubsystem->AddLog(
36+
SentrySubsystem->LogInfo(
3837
FString::Printf(TEXT("Purchase completed - User: %s, Tier: %s, Value: %.2f"),
3938
*UserId, *UserTier, PurchaseValue),
40-
ESentryLevel::Info,
4139
TEXT("IAP")
4240
);
4341

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

5855
```cpp
5956
// ❌ Inconsistent categories
60-
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("player"));
61-
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("Player"));
62-
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("PLAYER"));
63-
SentrySubsystem->AddLog(TEXT("..."), ESentryLevel::Info, TEXT("PlayerSystem"));
57+
SentrySubsystem->LogInfo(TEXT("..."), TEXT("player"));
58+
SentrySubsystem->LogInfo(TEXT("..."), TEXT("Player"));
59+
SentrySubsystem->LogInfo(TEXT("..."), TEXT("PLAYER"));
60+
SentrySubsystem->LogInfo(TEXT("..."), TEXT("PlayerSystem"));
6461

6562
// ✅ Consistent PascalCase categories
66-
SentrySubsystem->AddLog(TEXT("Player spawned"), ESentryLevel::Info, TEXT("Player"));
67-
SentrySubsystem->AddLog(TEXT("Player died"), ESentryLevel::Warning, TEXT("Player"));
68-
SentrySubsystem->AddLog(TEXT("Player score updated"), ESentryLevel::Debug, TEXT("Player"));
63+
SentrySubsystem->LogInfo(TEXT("Player spawned"), TEXT("Player"));
64+
SentrySubsystem->LogWarning(TEXT("Player died"), TEXT("Player"));
65+
SentrySubsystem->LogDebug(TEXT("Player score updated"), TEXT("Player"));
6966
```

‎platform-includes/logs/options/unreal.mdx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ The following configuration options are available for Sentry Logs in Unreal Engi
22

33
| Option | Description | Default |
44
|--------|-------------|------------|
5-
| **Enable Debug Logs** | Forward Debug level UE_LOG calls to Sentry | `false` |
6-
| **Enable Info Logs** | Forward Info level UE_LOG calls to Sentry | `false` |
7-
| **Enable Warning Logs** | Forward Warning level UE_LOG calls to Sentry | `false` |
8-
| **Enable Error Logs** | Forward Error level UE_LOG calls to Sentry | `false` |
9-
| **Enable Fatal Logs** | Forward Fatal level UE_LOG calls to Sentry | `false` |
5+
| **VeryVerbose** | Forward VeryVerbose UE_LOG calls to Sentry as Trace level logs | `false` |
6+
| **Verbose** | Forward Verbose UE_LOG calls to Sentry as Debug level logs | `false` |
7+
| **Display/Log** | Forward Display and Log UE_LOG calls to Sentry as Info level logs | `false` |
8+
| **Warning** | Forward Warning UE_LOG calls to Sentry as Warning level logs | `false` |
9+
| **Error** | Forward Error UE_LOG calls to Sentry as Error level logs | `false` |
10+
| **Fatal** | Forward Fatal UE_LOG calls to Sentry as Fatal level logs | `false` |
1011
| **Send Logs As Breadcrumbs** | Send UE_LOG calls BOTH as Logs and as Breadcrumbs, instead of just Logs | `false` |
1112
| **Log Category Filter** | Array of log categories to include (empty = all categories) | Empty |
1213
| **Before Log Callback** | Handler to modify or filter log events before sending | None |

‎platform-includes/logs/setup/unreal.mdx‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem
1515
SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
1616
{
1717
// Enable specific severity levels for UE_LOG forwarding
18+
Settings->StructuredLoggingLevels.bOnTraceLog = false;
1819
Settings->StructuredLoggingLevels.bOnDebugLog = false;
1920
Settings->StructuredLoggingLevels.bOnInfoLog = true;
2021
Settings->StructuredLoggingLevels.bOnWarningLog = true;
@@ -25,6 +26,17 @@ SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::Create
2526
}));
2627
```
2728
29+
The SDK maps `UE_LOG` verbosity to structured log levels as follows:
30+
31+
| `UE_LOG` verbosity | Setting | Sentry Logs UI Severity |
32+
| --- | --- | --- |
33+
| `Fatal` | `bOnFatalLog` | FATAL |
34+
| `Error` | `bOnErrorLog` | ERROR |
35+
| `Warning` | `bOnWarningLog` | WARN |
36+
| `Display`, `Log` | `bOnInfoLog` | INFO |
37+
| `Verbose` | `bOnDebugLog` | DEBUG |
38+
| `VeryVerbose` | `bOnTraceLog` | TRACE |
39+
2840
#### Log Category Filtering
2941
3042
You can filter which log categories are sent to Sentry:
@@ -63,8 +75,8 @@ class UCustomLogFilter : public USentryBeforeLogHandler
6375
public:
6476
virtual USentryLog* HandleBeforeLog_Implementation(USentryLog* LogData) override
6577
{
66-
// Filter out all debug logs
67-
if (LogData->GetLevel() == ESentryLevel::Debug)
78+
// Filter out all trace and debug logs
79+
if (LogData->GetLevel() == ESentryLogLevel::Trace || LogData->GetLevel() == ESentryLogLevel::Debug)
6880
{
6981
return nullptr; // Return null to prevent sending
7082
}
@@ -93,6 +105,7 @@ SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);
93105
void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
94106
{
95107
// Configure individual severity levels
108+
Settings->StructuredLoggingLevels.bOnTraceLog = false;
96109
Settings->StructuredLoggingLevels.bOnDebugLog = false;
97110
Settings->StructuredLoggingLevels.bOnInfoLog = true;
98111
Settings->StructuredLoggingLevels.bOnWarningLog = true;
@@ -111,9 +124,9 @@ SentrySubsystem->InitializeWithSettings(SettingsDelegate);
111124
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.
112125
113126
The `USentryLog` object has the following methods:
114-
- `GetLevel()`: Returns the severity level of the log (`ESentryLevel`)
127+
- `GetLevel()`: Returns the severity level of the log (`ESentryLogLevel`)
115128
- `GetBody()`: Returns the formatted log message (`FString`)
116-
- `SetLevel(ESentryLevel Level)`: Sets the Level of the Log Event
129+
- `SetLevel(ESentryLogLevel Level)`: Sets the Level of the Log Event
117130
- `SetBody(FString& Body)`: Sets the Body of the Log Event
118131
- `SetAttribute(Key, Value)`: Sets a custom attribute on the log
119132
- `GetAttribute(Key)`: Gets an attribute value

‎platform-includes/logs/usage/unreal.mdx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SentrySubsystem->LogWarningWithAttributes(
4141
```
4242

4343
Each log level has a corresponding method with attributes support:
44+
- `LogTraceWithAttributes()`
4445
- `LogDebugWithAttributes()`
4546
- `LogInfoWithAttributes()`
4647
- `LogWarningWithAttributes()`
@@ -77,6 +78,7 @@ Sentry Logs supports the following log levels:
7778
7879
| Method | Sentry Logs UI Severity |
7980
| --- | --- |
81+
| `LogTrace()` | TRACE |
8082
| `LogDebug()` | DEBUG |
8183
| `LogInfo()` | INFO |
8284
| `LogWarning()` | WARN |
@@ -85,6 +87,7 @@ Sentry Logs supports the following log levels:
8587
8688
```cpp
8789
// Examples of different log levels
90+
SentrySubsystem->LogTrace(TEXT("Inventory update started"), TEXT("Inventory"));
8891
SentrySubsystem->LogDebug(TEXT("Player position updated"), TEXT("Player"));
8992
SentrySubsystem->LogInfo(TEXT("Level loaded successfully"), TEXT("GameFlow"));
9093
SentrySubsystem->LogWarning(TEXT("Low memory warning"), TEXT("Performance"));
@@ -100,7 +103,8 @@ When structured logging is enabled with the appropriate severity levels, the SDK
100103
// Standard Unreal Engine logging - automatically captured when severity levels are enabled
101104
UE_LOG(LogGameFlow, Warning, TEXT("Player health is critically low: %d"), PlayerHealth);
102105
UE_LOG(LogAssets, Error, TEXT("Failed to load texture: %s"), *TexturePath);
103-
UE_LOG(LogTemp, Log, TEXT("Debug information")); // Only sent if EnableInfoLogs = true
106+
UE_LOG(LogTemp, Log, TEXT("Debug information")); // Only sent if StructuredLoggingLevels.bOnInfoLog = true
107+
UE_LOG(LogTemp, VeryVerbose, TEXT("Trace information")); // Sent as a trace log if StructuredLoggingLevels.bOnTraceLog = true
104108
```
105109

106110
You can configure whether these logs are sent as:

0 commit comments

Comments
 (0)