Skip to content

api - in production only log error responses to reduce logging

ryanlong requested to merge api_logs into main

Created by: deepakduggirala

This PR introduces conditional logging based on the environment mode (production or development). It configures different logging levels for HTTP requests:

  • In production, logs are recorded only for requests with status codes 400 or higher, using the 'combined' format.
  • In non-production (e.g., development), a more detailed 'dev' log format is used for all requests.

Production:

::1 - - [27/Nov/2024:06:21:42 +0000] "GET /combined HTTP/1.1" 401 2 "-" "curl/8.7.1"

Other envs:

GET /dev 200 0.224 ms - 2

more details: https://github.com/expressjs/morgan

Merge request reports

Loading