Skip to main content

Typegoose Logger

Typegoose uses loglevel to make some soft-errors and for debugging.

Set the LogLevel

Currently available loglevels:

  • SILENT (logs nothing | turns the logger off [not recommended])
  • WARN (default), used for soft errors / soft mistakes (everything below is mostly for debugging)
  • INFO
  • TRACE (shows everything)

To set the loglevel of Typegoose:

import { setLogLevel, LogLevels } from '@typegoose/typegoose';

// or

Enable Debug Logger

The import and call of setLogLevel needs to be placed before any other imports of the project entries file, because all decorators on a Class are executed on the context level they are on (commonly the module root).

// Project Entry file
import { setLogLevel } from "@typegoose/typegoose";

import { anythingElse } from "someModule";
import { SomeModel } from "./someModel";

// the rest of the main entry file