Logging allows you to see what is happening inside the Vendure server. It is useful for debugging and for monitoring the health of the server in production.
In Vendure, logging is configured using the logger property of the VendureConfig object. The logger must implement the VendureLogger interface.
To implement a custom logger, see the Implementing a custom logger guide.
Vendure uses 5 log levels, in order of increasing severity:
| Level | Description |
|---|---|
Debug | The most verbose level, used for debugging purposes. The output can be very noisy at this level |
Verbose | More information than the Info level, but less than Debug |
Info | General information about the normal running of the server |
Warning | Issues which might need attention or action, but which do not prevent the server from continuing to run. |
Error | Errors which should be investigated and handled; something has gone wrong. |
Vendure ships with a DefaultLogger which logs to the console (process.stdout). It can be configured with the desired log level:
To log database queries, set the logging property of the dbConnectionOptions as well as setting the logger to Debug level.
More information about the logging option can be found in the TypeORM logging documentation.
When you extend Vendure by creating your own plugins, it's a good idea to log useful information about what your plugin is doing. To do this, you need to import the Logger class from @vendure/core and use it in your plugin: