Skip to content

Allow logging REST endpoint mappings independent of other log categories #26539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lrozenblyum opened this issue Feb 11, 2021 · 4 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@lrozenblyum
Copy link

lrozenblyum commented Feb 11, 2021

Affects: Spring Web MVC 5.3.3

After upgrading from Spring4 to Spring5.3 we face a problem: there is no easy way to log just mappings of Controllers to endpoints.

The expected scenario: during booting a Spring MVC web application we would like to have all endpoint mappings in logs. However we don't want all request processing by Spring MVC to be logged because it would generate enormous amount of logs in production.

Currently, if we enable TRACE log level for org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
we receive both needed logs during boot of the webapp but also all requests processed are logged RequestMappingHandlerMapping - Mapped to ...).

Please provide a way to just log the endpoint mappings.

The issue was discussed in SO: https://stackoverflow.com/questions/40621044/log-restful-endpoints-on-container-startup-in-a-spring-application

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 11, 2021
@sbrannen sbrannen changed the title Allow logging REST endpoints mappings without additional overhead Allow logging REST endpoint mappings without additional overhead Feb 11, 2021
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Feb 11, 2021
@rstoyanchev rstoyanchev self-assigned this Feb 16, 2021
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 16, 2021
@rstoyanchev rstoyanchev added this to the 5.3.5 milestone Feb 16, 2021
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Feb 16, 2021

This has been discussed before. The number of endpoints can vary a lot. For a few controllers it is not an issue but for most applications tens or hundreds of endpoints is too much and floods log output. If necessary to show for debugging, mappings can be enabled at TRACE, as you have done, but otherwise they don't need to shown on every startup.

At runtime you can also use Boot's actuator to check mappings.

That aside we can create a log category that can be used to control the logging of handler mappings only.

@lrozenblyum
Copy link
Author

I see, thanks for the explanation, @rstoyanchev!
Creating a log category of handler mappings only seems very reasonable and will help solving the issue!

@lrozenblyum
Copy link
Author

Thanks @rstoyanchev !

@rstoyanchev rstoyanchev changed the title Allow logging REST endpoint mappings without additional overhead Allow logging REST endpoint mappings independent of other log categories Mar 15, 2021
This was referenced Mar 17, 2021
@aksh1618
Copy link
Contributor

aksh1618 commented Jun 6, 2021

@rstoyanchev This seems to have changed the logging level for Router functions:
3ec0452#diff-b43a2a2d87bedde90be033f4385b612063629834aad947032847ab7ff5563fd5L159
This logging was helpful to see dynamically created routes that were populated by a configuration based route generation spring boot based library we are using internally. Is there a way to enable it using properties, or in some other way without the library clients having to modify their logging configuration?

lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants