You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(dart/flutter): improve distinction between Logging integration and Structured Logs (#14527)
The logging integration refers to the integration with the Dart Logging
package and it's pretty easy to confuse it with Structured Logs
especially because if you google for Sentry Dart/Flutter logs the
logging integration is the first page that shows up
I tried to make it a bit more clearer but I'm unsure if my approach is
good
---------
Co-authored-by: Alex Krawiec <[email protected]>
description: "Learn more about the Sentry Logging integration for the Dart SDK."
3
+
description: "Integrate Sentry with the Dart Logging package to capture events, breadcrumbs, and automatically send structured logs to Sentry."
4
4
caseStyle: canonical
5
5
supportLevel: production
6
6
sidebar_order: 3
@@ -9,9 +9,19 @@ platforms:
9
9
- flutter
10
10
---
11
11
12
-
The `sentry_logging` library provides [Logging](https://pub.dev/packages/logging) support for Sentry using the [onRecord property](https://pub.dev/documentation/logging/latest/logging/Logger/onRecord.html). It is able to collect breadcrumbs and capture events. Once this integration is configured, you can use Logging's public API exclusively or in combination to the Sentry's SDK API to capture and enrich events.
12
+
This integration connects Sentry with the popular [Dart logging package](https://pub.dev/packages/logging), providing the following capabilities:
13
13
14
-
The source can be found [on GitHub](https://github.com/getsentry/sentry-dart/tree/main/logging/).
14
+
- If `enableLogs` is set to `true`, Sentry will send your log messages as [Sentry Structured Logs](/platforms/dart/logs/) (new in `9.5.0`)
15
+
- Captures breadcrumbs from your log calls
16
+
- Converts error-level logs into Sentry error events
17
+
- Works with your existing logging code
18
+
19
+
<Alertlevel="info">
20
+
21
+
This page covers the instrumentation of the **Dart Logging package**.
22
+
This integration also supports creating structured logs. However, if you're looking to set up Sentry structured logs in general, visit our [Structured Logs](/platforms/dart/logs/) documentation.
23
+
24
+
</Alert>
15
25
16
26
## Install
17
27
@@ -26,8 +36,7 @@ dependencies:
26
36
27
37
## Configure
28
38
29
-
Configuration should happen as early as possible in your application's lifecycle.
30
-
39
+
Add the `LoggingIntegration` to your `Sentry.init` call:
Learn more about manually capturing an error or message, in our <PlatformLinkto="/usage/">Usage documentation</PlatformLink>.
70
-
71
-
</Alert>
72
-
73
-
To view and resolve the recorded message, log into [sentry.io](https://sentry.io) and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
107
+
### What You'll See in Sentry:
108
+
-**Breadcrumbs**: All three log calls will appear as breadcrumbs on the error event
109
+
-**Error Event**: The `severe` log creates a full error event with stack trace
110
+
-**Structured Logs**: (if `enableLogs` is `true`) Navigate to **Logs** in your Sentry project to see all three entries as searchable structured logs
Copy file name to clipboardExpand all lines: platform-includes/logs/usage/dart.mdx
+26-7Lines changed: 26 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,33 @@ Once the feature is enabled on the SDK and the SDK is initialized, you can send
2
2
3
3
The `logger` namespace exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warning`, `error`, and `fatal`.
4
4
5
-
You can pass additional attributes directly to the logging functions. These properties will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
5
+
Aside from the primary logging methods, we've provided a format text function, `Sentry.logger.fmt`, that you can use to insert properties into to your log entries.
6
+
7
+
These properties will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
8
+
9
+
<Alertlevel="info">
10
+
When using the `fmt` function, you must use the `%s` placeholder for each value you want to insert.
11
+
</Alert>
6
12
7
13
```dart
8
-
Sentry.logger.info("A simple log message");
9
-
Sentry.logger.warn("This is a warning log with attributes.", attributes: {
0 commit comments