DocsObservabilityLogging

Logging

In Mastra, logs can detail when certain functions run, what input data they receive, and how they respond.

Basic Setup

Here’s a minimal example that sets up a console logger at the INFO level. This will print out informational messages and above (i.e., DEBUG, INFO, WARN, ERROR) to the console.

mastra.config.ts
import { Mastra } from "@mastra/core";
import { createLogger } from "@mastra/core/logger";
 
export const mastra = new Mastra({
  // Other Mastra configuration...
  logger: createLogger({
    name: "Mastra",
    level: "info",
  }),
});

In this configuration:

  • name: "Mastra" specifies the name to group logs under.
  • level: "info" sets the minimum severity of logs to record.

Configuration