
setLoggersetLogger is an optional function that allows you to replace the default logger used by React Query to log errors. By default, the window.console object is used. If no global console object is found in the environment, nothing will be logged.
Examples:
import { setLogger } from 'react-query'import { printLog, printWarn, printError } from 'custom-logger'// Custom loggersetLogger({log: printLog,warn: printWarn,error: printError,})// Sentry loggersetLogger({log: message => {Sentry.captureMessage(message)},warn: message => {Sentry.captureMessage(message)},error: error => {Sentry.captureException(error)},})// Winston loggersetLogger(winston.createLogger())
Options
logger: Loggerlog, warn, and error methods.The latest TanStack news, articles, and resources, sent to your inbox.