Set the Level
The level - similar to logging levels - is generally added by default based on the integration. You can also override it within an event.
To set the level out of scope, you can call captureMessage()
per event:
Copied
Sentry.captureMessage("this is a debug message", "debug");
Available levels are "fatal"
, "error"
, "warning"
, "log"
, "info"
, and "debug"
.
To set the level within scope, you can call setLevel()
:
Copied
Sentry.getCurrentScope().setLevel("warning");
or per event:
Copied
Sentry.withScope(function (scope) {
scope.setLevel("info");
// The exception has the event level set by the scope (info).
Sentry.captureException(new Error("custom error"));
});
// Outside of withScope, the Event level will have their previous value restored.
// The exception has the event level set (error).
Sentry.captureException(new Error("custom error 2"));
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/node
- Version:
- 7.110.0
- Repository:
- https://github.com/getsentry/sentry-javascript