Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

Avoid high-severity logging for 404 errors, which are normal

Open ijackson opened this issue 5 months ago • 3 comments

API Docs to Existing Functionality

https://rocket.rs/guide/v0.5/requests/#error-catchers

Problems with Existing Functionality

Currently, rocket logs a message at level ERROR whenever no route matches:

2025-06-30T17:05:42.542694Z ERROR rocket::server::_: No matching routes for ESC[32mGETESC[0m ESC[34m/.idea/workspace.xmlESC[0m.    
2025-06-30T17:05:42.542766Z  WARN rocket::server::_: No ESC[1;34m404ESC[0m catcher registered. Using Rocket default.    

Or with a default error catcher installed:

2025-07-23T13:33:49.967921Z ERROR rocket::server::_: No matching routes for GET /no-such-document.    
2025-07-23T13:33:49.968089Z  WARN rocket::server::_: Responding with registered (error_handler) default catcher.    

For a webserver facing the public internet, probes for nonexistent paths are normal. They should not generate high-severity log messages.

This is operationally important, because the webserver's ERROR, WARN and INFO logs will otherwise be swamped with useless information. On systems with space-based log rotation, this can cause important messages about actual misconfigurations to be quickly lost; on systems with time-based log rotation, it could fill up the disk and break the service.

This definitely applies to 404 errors but it may apply to others too.

Suggested Changes

I suggest the following changes:

  • The "No matching routes" message ought to be at level DEBUG or TRACE.
  • The "Responding with registered ... default catcher" message should be at leavel TRACE. The error catcher can log at a higher severity if it wishes.

Alternatives Considered

My application could try to install a default route but it ought to apply to all methods but there is no way to make an "all-methods" route (#2731). And this issue doesn't seem application-specific.

Additional Context

I didn't find any documentation about what happens when no route matches.

System Checks

  • [x] I do not believe that this suggestion can or should be implemented outside of Rocket.

  • [x] I was unable to find a previous suggestion for this change.

ijackson avatar Jul 23 '25 14:07 ijackson

I've also seen this warning:

2025-07-24T22:55:03.349714Z  WARN tag2upload_service_manager::ui_routes::_: Request guard `UiReqInfo` is forwarding.    

Looking at the documentation, a request guard (FromRequest impl) forwarding (Outcome::Forward) is normal occurrence.

ijackson avatar Jul 24 '25 23:07 ijackson

I have this annoying message in my debug.log, in the release mode:

No 404 catcher registered. Using Rocket default.

How to silentize it?

oooo-ps avatar Aug 10 '25 03:08 oooo-ps

I ran into the same issue, but when going to submit a PR I noticed that on master, the "no matching routes" log statement doesn't exist anymore, and the "no catcher" / "default catcher" ones were downgraded to info level. So, as a workaround for myself, I updated my rocket dependency to point to 0.6.0-dev / master.

stadust avatar Aug 10 '25 10:08 stadust