---
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/godot/logs/
---

# Set Up Logs | Sentry for Godot Engine

With Sentry Structured Logs, you can send text-based log information from your Godot 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/godot/logs.md#requirements)

Logs for Godot Engine are supported in Sentry Godot SDK version `1.1.0` and above. Starting with version `1.2.0`, the feature is generally available.

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

To enable logging in your Godot project, you need to configure the Sentry SDK with Logs enabled.

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

1. Navigate to **Project Settings** in Godot
2. Go to **Sentry > Options**
3. Check the **Enable Logs** option

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

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

```GDScript
SentrySDK.init(func(options: SentryOptions) -> void:
	options.enable_logs = true
)
```

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

Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `SentrySDK.logger` APIs.

The `SentrySDK.logger` exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warn`, `error`, and `fatal`.

```GDScript
SentrySDK.logger.trace("Initialized inventory database")
SentrySDK.logger.debug("Player inventory updated")
SentrySDK.logger.info("Level loaded successfully")
SentrySDK.logger.warn("Item configuration not found")
SentrySDK.logger.error("Failed to save game state")
SentrySDK.logger.fatal("Inventory data corrupted")
```

The methods support string interpolation using Godot's format strings syntax. The log message can contain format placeholders (e.g., `%s`, `%d`), and the optional `parameters` array provides values to substitute into placeholders using Godot's format strings. These will be sent to Sentry as log attributes, and can be searched from within the Logs UI.

```GDScript
# String interpolation automatically extracts parameters as log attributes
SentrySDK.logger.info("Spawned %d enemies on level %s", [5, "forest_1"])

# This is equivalent to manually specifying attributes:
var message := "Spawned %d enemies on level %s" % [5, "forest_1"]
SentrySDK.logger.info(message, [], {
	"sentry.message.template": "Spawned %d enemies on level %s",
	"sentry.message.parameter.0": 5,
	"sentry.message.parameter.1": "forest_1"
})
```

You can also use structured attributes to provide additional context for your logs. For example, you can add a `current_scene` attribute to log messages related to currently loaded scene.

```GDScript
# Adding custom attributes, which can be searched from within the Logs UI
SentrySDK.logger.debug("Spawning %s with %d units", ["enemies", 5], {
	"current_scene": get_tree().current_scene.scene_file_path,
	"wave_id": "main_wave_3"
})
```

Structured attributes support `bool`, `int`, `float`, and `String` data types. Other types will be converted to strings.

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

You can set global attributes that are automatically included in all log entries and metrics. This is useful for attaching contextual information like player IDs or game state that should appear on every log.

```GDScript
# Set global attributes that apply to all logs and metrics
SentrySDK.set_attribute("level", "castle")
SentrySDK.set_attribute("difficulty", "hard")

# All subsequent logs will include these attributes
SentrySDK.logger.info("Level loaded")

# Clear when returning to the main menu
SentrySDK.remove_attribute("level")
```

### [Godot Logging Integration](https://docs.sentry.io/platforms/godot/logs.md#godot-logging-integration)

When the feature is enabled, the SDK automatically captures Godot messages, warnings, and errors as logs. You can use `print()`, `push_warning()`, and `push_error()` as usual. These show up as `info`, `warning`, and `error` logs. The SDK also turns runtime errors and warnings into events based on your configuration.

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

### [before\_send\_log](https://docs.sentry.io/platforms/godot/logs.md#before_send_log)

To filter logs, or update them before they are sent to Sentry, you can use the `before_send_log` option.

```GDScript
SentrySDK.init(func(options: SentryOptions) -> void:
	options.enable_logs = true
	options.before_send_log = _before_send_log
)

func _before_send_log(log_entry: SentryLog) -> SentryLog:
	# Filter junk.
	if log_entry.body == "Junk message":
		return null
	# Remove sensitive information from log messages.
	log_entry.body = log_entry.body.replace("Bruno", "REDACTED")
	# Add custom attributes.
	log_entry.set_attribute("current_scene", current_scene.name)
	return log_entry
```

The `before_send_log` function receives a `SentryLog` object, and should return either the same log object, with or without modifications, or `null` if you want to discard it.

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

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

### [Core Attributes](https://docs.sentry.io/platforms/godot/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/godot/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.

### [Integration Attributes](https://docs.sentry.io/platforms/godot/logs.md#integration-attributes)

If a log is generated by an SDK integration, the SDK will set additional attributes to help you identify the source of the log.

* `origin`: The origin of the log. This is sent from the SDK as `sentry.origin`.

## [Troubleshooting](https://docs.sentry.io/platforms/godot/logs.md#troubleshooting)

### [Performance Considerations](https://docs.sentry.io/platforms/godot/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.
* `before_send_log` callback is executed synchronously, so keep processing lightweight.
