# Logging (Prisma ORM v7) (/docs/orm/v7/prisma-client/observability-and-logging/logging) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Learn how to configure Prisma Client to log the raw SQL queries it sends to the database and other information Location: ORM > v7 > Prisma Client > Observability and Logging > Logging Use the `PrismaClient` [`log`](https://www.prisma.io/docs/orm/v7/reference/prisma-client-reference#log) parameter to configure [log levels](https://www.prisma.io/docs/orm/v7/reference/prisma-client-reference#log-levels) , including warnings, errors, and information about the queries sent to the database. Prisma Client supports two types of logging: * Logging to [stdout](https://en.wikipedia.org/wiki/Standard_streams) (default) * Event-based logging (use [`$on()`](https://www.prisma.io/docs/orm/v7/reference/prisma-client-reference#on) method to [subscribe to events](#event-based-logging)) > [!NOTE] > You can also use the `DEBUG` environment variable to enable debugging output in Prisma Client. See [Debugging](https://www.prisma.io/docs/orm/v7/prisma-client/debugging-and-troubleshooting/debugging) for more information. > [!NOTE] > If you want a detailed insight into your Prisma Client's performance at the level of individual operations, see [Tracing](https://www.prisma.io/docs/orm/v7/prisma-client/observability-and-logging/opentelemetry-tracing). ## Log to stdout [#log-to-stdout] The simplest way to print *all* log levels to stdout is to pass in an array `LogLevel` objects: ```ts const prisma = new PrismaClient({ log: ["query", "info", "warn", "error"], }); ``` This is the short form of passing in an array of `LogDefinition` objects where the value of `emit` is always `stdout`: ```ts const prisma = new PrismaClient({ log: [ { emit: "stdout", level: "query", }, { emit: "stdout", level: "error", }, { emit: "stdout", level: "info", }, { emit: "stdout", level: "warn", }, ], }); ``` ## Event-based logging [#event-based-logging] To use event-based logging: 1. Set `emit` to `event` for a specific log level, such as query 2. Use the `$on()` method to subscribe to the event The following example subscribes to all `query` events and write the `duration` and `query` to console: #### Relational databases ```ts highlight=4,5,22-26;normal const prisma = new PrismaClient({ log: [ { emit: "event", level: "query", }, { emit: "stdout", level: "error", }, { emit: "stdout", level: "info", }, { emit: "stdout", level: "warn", }, ], }); prisma.$on("query", (e) => { console.log("Query: " + e.query); console.log("Params: " + e.params); console.log("Duration: " + e.duration + "ms"); }); ``` ```sql Query: SELECT "public"."User"."id", "public"."User"."email", "public"."User"."name" FROM "public"."User" WHERE 1=1 OFFSET $1 Params: [0] Duration: 3ms Query: SELECT "public"."Post"."id", "public"."Post"."title", "public"."Post"."authorId" FROM "public"."Post" WHERE "public"."Post"."authorId" IN ($1,$2,$3,$4) OFFSET $5 Params: [2, 7, 18, 29] Duration: 2ms ``` #### MongoDB ```ts highlight=4,5,22-25;normal const prisma = new PrismaClient({ log: [ { emit: "event", level: "query", }, { emit: "stdout", level: "error", }, { emit: "stdout", level: "info", }, { emit: "stdout", level: "warn", }, ], }); prisma.$on("query", (e) => { console.log("Query: " + e.query); }); ``` ```bash Query: db.User.aggregate([ { $project: { _id: 1, email: 1, name: 1, }, }, ]) Query: db.Post.aggregate([ { $match: { userId: { $in: [ "622f0bbbdf635a42016ee325", ], }, }, }, { $project: { _id: 1, slug: 1, title: 1, body: 1, userId: 1, }, }, ]) ``` The exact [event (`e`) type and the properties available](https://www.prisma.io/docs/orm/v7/reference/prisma-client-reference#event-types) depends on the log level. ## Related pages - [`OpenTelemetry tracing`](https://www.prisma.io/docs/orm/v7/prisma-client/observability-and-logging/opentelemetry-tracing): Diagnose application performance with detailed traces of each query - [`SQL comments`](https://www.prisma.io/docs/orm/v7/prisma-client/observability-and-logging/sql-comments): Add metadata to your SQL queries as comments for improved observability, debugging, and tracing