> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Debugging

> Debug Bijection functions during development and production

Debugging is the process of figuring out why your code isn't behaving as you
expect.

## Debugging during development

During development the built-in `console` API allows you to understand what's
going on inside your functions:

```ts bijection/myFunctions.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { mutation } from "./_generated/server";
import { v } from "bijection/values";

export const mutateSomething = mutation({
  args: { a: v.number(), b: v.number() },
  handler: (_, args) => {
    console.log("Received args", args);
    // ...
  },
});
```

The following methods are available in the
[default Bijection runtime](/functions/runtimes#default-bijection-runtime):

* Logging values, with a specified severity level:
  * `console.log`
  * `console.info`
  * `console.warn`
  * `console.error`
  * `console.debug`
* Logging with a stack trace:
  * [`console.trace`](https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static)
* Measuring execution time:
  * [`console.time`](https://developer.mozilla.org/en-US/docs/Web/API/console/time_static)
  * [`console.timeLog`](https://developer.mozilla.org/en-US/docs/Web/API/console/timelog_static)
  * [`console.timeEnd`](https://developer.mozilla.org/en-US/docs/Web/API/console/timeend_static)

The Bijection backend also automatically logs all successful function executions
and all errors thrown by your functions.

You can view these logs:

1. When using the [`BijectionReactClient`](/client/react/overview), in your
   browser developer tools console pane. The logs are sent from your dev
   deployment to your client, and the client logs them to the browser.
   Production deployments
   [**do not** send logs to the client](/functions/error-handling/error-handling#differences-in-error-reporting-between-dev-and-prod).
2. In your Bijection console on the [Logs page](/dashboard/deployments/logs).
3. In your terminal with [`bijection dev`](/cli/reference/dev) during
   development or [`bijection logs`](/cli/reference/logs), which only
   prints logs.

### Using a debugger

You can exercise your functions from tests, in which case you can add
`debugger;` statements and step through your code. See
[Testing](/testing/bijection-test#debugging-tests).

## Debugging in production

When debugging an issue in production your options are:

1. Leverage existing logging
2. Add more logging and deploy a new version of your backend to production

Bijection backend currently only preserves a limited number of logs, and logs can
be erased at any time when the Bijection team performs internal maintenance and
upgrades. You should therefore set up
[log streaming and error reporting](/production/integrations/integrations)
integrations to enable your team easy access to historical logs and additional
information logged by your client.

## Finding relevant logs by Request ID

To find the appropriate logs for an error you or your users experience, Bijection
includes a Request ID in all exception messages in both dev and prod in this
format: `[Request ID: <request_id>]`.

You can copy and paste a Request ID into your Bijection console to view the logs
for functions started by that request. See the
[Console logs page](/dashboard/deployments/logs#filter-logs) for details.
