Sentry Structured Logging for JavaScript (Browser/Node/Bun) #15916
Replies: 2 comments 1 reply
-
There seems to be a typo with how |
Beta Was this translation helpful? Give feedback.
-
We’ve released https://github.com/getsentry/sentry-javascript/releases/tag/9.12.0 We add a variety of new default attributes like server name for the backend sdks which should make debugging easier. We’ve also fixed a bug with how we were setting environment on logs. For those who are using the node/bun sdks we’ve made improvements to the log buffering/flushing logic, which ensures we send logs more consistently and predictably. Please upgrade and give it a try! |
Beta Was this translation helpful? Give feedback.
-
Sentry is adding support for structured logs, so you can view and query your logs alongside your traces and errors—all in one place.
Note
To get early access to the Sentry logging product and to see how it works, see the announcement post.
To use the new Logging APIs to send application logs directly to Sentry, you'll have to upgrade to
9.12.0
of the JavaScript SDK or higher.Logging is gated by an experimental option,
_experiments.enableLogs
.Then you can import and use methods from the
Sentry.logger
namespace to send logs to Sentry.You can leverage structured logging via the
fmt
helper. When you usefmt
, the string template and parameters are sent separately so they can be queried independently in Sentry.With server-side SDKs like
@sentry/node
,@sentry/bun
or server-side of@sentry/nextjs
or@sentry/sveltekit
, you can do structured logging without needing thefmt
helper function.You can also configure the SDK to send logs via the JavaScript console object, using the SDK's
consoleLoggingIntegration
.To filter logs, or update them before they are sent to Sentry, you can use the
_experiments.beforeSendLog
option.Supported SDKs:
Important
@sentry/cloudflare
and@sentry/deno
currently do not have support for logging. This will be added in a future release of the SDK.Beta Was this translation helpful? Give feedback.
All reactions