Not logging 404 "page not found"

Created on 11 June 2025, 4 months ago

Problem/Motivation

With the fast404 module enabled i cannot get the "page not found" exception to produce logs.
I'm using monolog to log 404's to syslog but with monolog disabled it wonñt log to db either.
While debugging i see that when "$settings['fast404_path_check'] = true" is set, the 'ExceptionLoggingSubscriber' is never called, seems like the kernel event 'onException' is never reached.
I can see how that might be intentional, to make the 404 reponse quicker and lighter. But in that case would it make sense to include some setting to be able to log if desired?

Somehting like this?

 $response = new Response(new FormattableMarkup($message, ['@path' => $this->request->getPathInfo()]), $return_gone ? 410 : 404, $headers);
    if ($return) {
      // Log the 404/410 error
      if (Settings::get('fast404_logging', FALSE)) {
          \Drupal::logger('page not found')->warning('Page not found: @path', ['@path' => $this->request->getPathInfo()]);
      }
      return $response;
    }

Steps to reproduce

with fast404 enabled i don't see 404 log messages.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

3.4

Component

Code

Created by

🇪🇸Spain tahiche

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024