Logs Events
Log events are distributed by Modern.js as events of type log.
Built-in Events
Based on server-side runtime logic, Modern.js provides the following log events:
Built-in Monitor
In Modern.js, log events are handled by LoggerMonitor, which outputs logs to the console.
The built-in LoggerMonitor depends on the rslog library.
For example, intentionally throwing an error in the project:
If running normally, you can see the following output in the console:
To configure the built-in production server logger with MODERN_SERVER_LOG_LEVEL, see Production server logs.
Request headers in error logs
Modern.js omits cookie, set-cookie, authorization, proxy-authorization, x-api-key, and x-proxy-auth when it logs request headers for SSR or server errors. Other headers, such as x-request-id, are available for troubleshooting.
Use server.logger.redactHeaders in modern.config.ts to add names to the default list. Header names are case-insensitive, so setting it to ['X-Internal-Token'] also filters x-internal-token.