Journalisation & Débogage
You are reading the documentation for version 2 of FoalTS. Instructions for upgrading to this version are available here. The old documentation can be found here.
#
HTTP Request LoggingFoalTS uses morgan to log the HTTP requests. You can specify the output format using the environment variable SETTINGS_LOGGER_FORMAT
or the config/default.json
file:
- YAML
- JSON
- JS
#
Disabling HTTP Request LoggingIn some scenarios and environments, you might want to disable http request logging. You can achieve this by setting the loggerFormat
configuration option to none
.
- YAML
- JSON
- JS
#
Disabling Error LoggingIn some scenarios, you might want to disable error logging (error stack traces that are displayed when an error is thrown in a controller or hook). You can achieve this by setting the allErrors
configuration option to false.
- YAML
- JSON
- JS
#
Logging HookFoalTS provides a convenient hook for logging debug messages: Log(message: string, options: LogOptions = {})
.
Example:
#
Advanced LoggingIf you need advanced logging, you might be interested in using winston, a popular logger in the Node.js ecosystem.
Here's an example on how to use it with Foal:
LoggerService
LogUserId hook
ProductController
AuthController