Docs
Try Apollo Studio

Logging in the Apollo Router


The Apollo Router accepts a command-line argument to set its log level:

NameDescription
--log

The log level, indicating the most severe log message type to include. In ascending order of verbosity, can be one of: off, error, warn, info, debug, or trace.

The default value is info.

The router also accepts an APOLLO_ROUTER_LOG environment variable with the same possible values as the command-line argument. If you provide both, the command-line argument takes precedence.

Output formats

The Apollo Router supports two logging formats:

  • Basic logging, primarily for local development
  • JSON-formatted logging, for compatibility with searchable logging tools like Google Cloud Logging

The router uses basic logging whenever an interactive shell session is attached, and it uses JSON-formatted logging otherwise (e.g., in CI and deployed environments).

Basic logging via shell

Basic logging is mostly used during local development:

2022-03-18T10:28:11.090054Z INFO apollo_router::executable: apollo-router@0.1.0-alpha.9
2022-03-18T10:28:11.160650Z INFO apollo_router: Starting Apollo Router
2022-03-18T10:28:11.339906Z INFO apollo_router: Listening on http://127.0.0.1:4000 🚀

JSON-formatted logging

JSON-formatted logging provides compatibility with common searchable logging tools like Google Cloud Logging. The Apollo Router uses the popular Bunyan format:

{"timestamp":"2022-03-18T11:46:41.926942Z","level":"INFO","fields":{"message":"apollo-router@0.1.0-alpha.9"},"target":"apollo_router::executable"}
{"timestamp":"2022-03-18T11:46:41.985121Z","level":"INFO","fields":{"message":"Starting Apollo Router"},"target":"apollo_router"}
{"timestamp":"2022-03-18T11:46:42.171173Z","level":"INFO","fields":{"message":"Listening on http://127.0.0.1:4000 🚀"},"target":"apollo_router"}
{"timestamp":"2022-03-18T11:46:43.453993Z","level":"INFO","fields":{"message":"Stopped"},"target":"apollo_router"}

Advanced configuration

For more granular control over Apollo Router logging, see the Env Logger documentation.

Edit on GitHub
Previous
CSRF prevention
Next
Header propagation