Skip to content

Commit 373b0dc

Browse files
committed
Add logs
1 parent 8b6742a commit 373b0dc

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Set Up Logs
3+
sidebar_title: Logs
4+
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
5+
sidebar_order: 5755
6+
---
7+
8+
<Include name="feature-stage-beta-logs.mdx" />
9+
10+
With Sentry Structured Logs, you can send text based log information from your applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.
11+
12+
## Setup
13+
14+
<PlatformContent includePath="logs/setup" />
15+
16+
## Usage
17+
18+
<PlatformContent includePath="logs/usage" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To enable logging, you need to initialize the SDK with the `enableLogs` option set to `true`.
2+
3+
```dart
4+
await SentryFlutter.init(
5+
(options) {
6+
options.dsn = "___PUBLIC_DSN___";
7+
// Enable logs to be sent to Sentry
8+
options.enableLogs = true;
9+
},
10+
);
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To enable logging, you need to initialize the SDK with the `enableLogs` option set to `true`.
2+
3+
```dart
4+
await Sentry.init(
5+
(options) {
6+
options.dsn = "___PUBLIC_DSN___";
7+
// Enable logs to be sent to Sentry
8+
options.enableLogs = true;
9+
},
10+
);
11+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `Sentry.logger` APIs.
2+
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+
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.
6+
7+
```dart
8+
Sentry.logger.info("A simple log message");
9+
Sentry.logger.warn("This is a warning log with attributes.", attributes: {
10+
'string-attribute': SentryLogAttribute.string('string'),
11+
'int-attribute': SentryLogAttribute.int(1),
12+
'double-attribute': SentryLogAttribute.double(1.0),
13+
'bool-attribute': SentryLogAttribute.bool(true),
14+
});
15+
```

0 commit comments

Comments
 (0)