#manually capture logs via enableLogs

2 messages · Page 1 of 1 (latest)

silent dove
#

Hey there,
I've setup a new org to test out logs. I'm installing via npm, and with a setup like

_experiments: {
  enableLogs: true,
},
integrations: [Sentry.consoleLoggingIntegration()]

I get console logs captured in Sentry and available under thew new feature page.

However, I can't figure out how to manually capture logs. I saw in this post that logger from @sentry/core is not the right logger for that. Since I'm running in a browser env, I've tried importing from @sentry/browser to no avail. Where's that magic logger that I need to import? The logs aren't helpful on this topic

Otherwise, love the feature so far 🤩
Thanks in advance
Matthias

winter sluice
#

You can import the logger like this:

// ...or the import from the SDK you are using
import * as Sentry from "@sentry/browser";
const { logger } = Sentry;

logger.trace("Trace", { database: "users" });
logger.debug(logger.fmt`User: ${userId}`);
logger.info("Info", { profileId: 345 });
logger.warn("Warn", {isEnterprise: false });