Hide successful XHR requests from log

Author: MetRonnieCreated Mar 29, 2023Updated Aug 7, 2026

I don't need to see any successful XHR requests in stdout. To try and turn this off I looked into the codebase and based on that, implemented a custom logger setup like so:

const jsonServer = require('json-server')
const logger = require('morgan')

const server = jsonServer.create()

const middlewares = [
  ...jsonServer.defaults({ logger: false }),
  logger('dev', {
    skip: (req, res) => res.statusCode < 400
  })
]

server.use(middlewares)

I guess this is pretty straightforward, still it would be nice if this was easier to do (and without having to straight up replace the logger (thus meaning I have to add morgan as a dev dependency of my project)).