Logging

The Descope backend SDKs can emit log messages to help you diagnose failed API calls, session validation errors, and configuration problems.

Support differs by language, and the SDKs do not share a common shape. Some take a log level, some take a logger object you supply.

SDKWhat you setLog levels
Node.jsA logger objectNone, so you filter inside the logger you supply
GoLogLevel, and optionally a Logger of your ownlogger.LogNone, logger.LogInfoLevel, and logger.LogDebugLevel
Rubylog_level, and optionally a logger of your owndebug, info, warn, error, fatal, and unknown
PHPdebug to true or falseNone

Enabling a Logger

The Node.js SDK takes a logger object rather than a log level. Pass it alongside projectId:

import DescopeClient from '@descope/node-sdk';

const descopeClient = DescopeClient({
  projectId: '__ProjectID__',
  logger: console,
});

During development you can pass console directly. To route messages into your own logging service, supply an object with debug, log, warn, and error methods:

const logger = {
  debug: (message, ...args) => myLogger.debug(message, ...args),
  log: (message, ...args) => myLogger.info(message, ...args),
  warn: (message, ...args) => myLogger.warn(message, ...args),
  error: (message, ...args) => myLogger.error(message, ...args),
};

const descopeClient = DescopeClient({
  projectId: '__ProjectID__',
  logger,
});

All four methods are required, which is why passing console works. The SDK calls error for failures, log for informational messages, and warn for non-fatal problems. Messages are emitted for session validation failures, refresh token validation failures, access key exchange failures, public key parsing errors, and license handshake problems.

Additional Resources

Was this helpful?

On this page