Skip to Content

log

The log configuration object allows you to control the logging behavior. Proper log configuration is essential for monitoring the router’s health, debugging issues, and gaining insight into its operations in both development and production environments.

You can control the verbosity, format, and filtering of the logs generated by the router.

Options

level

  • Type: string
  • Default: info

The level property controls the verbosity of the logs. By default, the router is configured to be mostly silent at the info level, emitting only important operational messages, warnings, and errors.

The available log levels, from most verbose to least, are:

  • trace: Highly detailed diagnostic information for deep debugging.
  • debug: Detailed information useful for tracking the flow of requests.
  • info: General operational information (e.g., server startup messages).
  • warn: Potentially harmful situations or warnings that do not stop execution.
  • error: Error events that might still allow the application to continue running.

format

  • Type: string
  • Default: json

The format property determines the structure of the log output.

  • json (Default): Outputs logs in a structured JSON format. This is the recommended format for production as it allows for easy parsing, filtering, and ingestion by log management systems (e.g., Datadog, Splunk, ELK stack).
  • pretty-tree: A human-readable, multi-line, tree-like format that is useful for local development and debugging. It is not recommended for production.
  • pretty-compact: A more compact, single-line, human-readable format, also intended for development.

filter

  • Type: string

The filter property provides advanced, fine-grained control over which log messages are emitted based on their origin (e.g., a specific module within the router) and their level. This can be used to reduce noise or focus on a particular area of the router without changing the global log level.

The syntax is a comma-separated list of target=level directives. For most use cases, adjusting the global level is sufficient.

Examples

Production Logging

This is a typical configuration for a production environment, logging only informational messages and above in a machine-readable JSON format.

router.config.yaml
log: level: 'info' format: 'json'

Development Logging

This configuration is useful for local development, providing more verbose debug output in a human-readable format.

router.config.yaml
log: level: 'debug' format: 'pretty-compact'
Last updated on