跳到主要內容

除錯

你可以透過 DEBUG 環境變數在 Prisma Client 和 Prisma CLI 中啟用除錯輸出。它接受兩個名稱空間來列印除錯輸出

  • prisma:engine: 列印 Prisma ORM 引擎中發生的除錯資訊
  • prisma:client: 列印 Prisma Client 執行時中發生的除錯資訊
  • prisma*: 列印 Prisma Client 或 CLI 的所有除錯資訊
  • *: 列印所有除錯資訊
資訊

Prisma Client 可以配置為記錄警告、錯誤以及與傳送到資料庫的查詢相關的資訊。有關更多資訊,請參閱配置日誌

設定 DEBUG 環境變數

以下是用於在 bash 中設定這些除錯選項的示例

# enable only `prisma:engine`-level debugging output
export DEBUG="prisma:engine"

# enable only `prisma:client`-level debugging output
export DEBUG="prisma:client"

# enable both `prisma-client`- and `engine`-level debugging output
export DEBUG="prisma:client,prisma:engine"

要啟用所有 prisma 除錯選項,請將 DEBUG 設定為 prisma*

export DEBUG="prisma*"

在 Windows 上,使用 set 而不是 export

set DEBUG="prisma*"

要啟用所有除錯選項,請將 DEBUG 設定為 *

export DEBUG="*"
© . This site is unofficial and not affiliated with Prisma Data, Inc.