PrismaP
Prisma2mo ago
7 replies
Spyda

Logging with Prisma v7

Hey all, given Prisma v7 now requires we use adapters when connecting to a database (see here - https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-7#driver-adapters-and-client-instantiation), how do we continue to use logging via emitted events i.e. the example here https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/logging ? Thestdout option works fine (outputs logs to stdout), but it seems like the below example snippet from the docs no longer works i.e. doesn't trigger an event and then console.log output. As a result, it's no longer possible to have a custom logger.

prisma.$on('query', (e) => {
  console.log('Query: ' + e.query)
  console.log('Params: ' + e.params)
  console.log('Duration: ' + e.duration + 'ms')
})
Learn how to configure Prisma Client to log the raw SQL queries it sends to the database and other information.
Logging | Prisma Documentation
Guide on how to upgrade to Prisma ORM 7
Upgrade to Prisma ORM 7 | Prisma Documentation
Was this page helpful?