Skip to content

disableRequestLogging should disable logs in default error handler #5409

@SamSalvatico

Description

@SamSalvatico

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.26.2

Plugin version

No response

Node.js version

v20.11.1

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

14.4.1

Description

I am trying to have a full control over the log entries Fastify writes and I noticed that in the default error handler it writes records without checking the disableRequestLogging value.

Should it check if and disable logging when it is true or is it preferred to set a custom error handler to prevent it?

Steps to Reproduce

import fastify from 'fastify';

const server = fastify({
    disableRequestLogging: true
});

server.get('/ping', async (request, reply) => {
    throw new Error('err');
})

server.listen({ port: 8080 }, (err, address) => {
    if (err) {
        process.exit(1)
    }
})

Expected Behavior

No log entries added when an error is managed by the default error handler

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions