Log restful endpoints on container startup in a Spring application

后端 未结 3 1587
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 16:11

I\'ve a Spring application that expose restful endpoints through @RequestMapping annotation in Controller classes.

I wish that were logged into the console, at serve

3条回答
  •  情深已故
    2020-12-10 16:57

    For those who use spring-boot:

    In the latest spring-boot release (since v2.1), they changed the mapping default log level (as specified in the Release Notes here).

    Add one of the following properties to application.properties file:

    • logging.level.web=TRACE
    • logging.level.org.springframework.web=TRACE

    Sample Console Output:

    2018-12-12 11:16:51.793 TRACE 11868 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping
        c.n.c.MyController:
        {POST /users}: addUser(User)
        {DELETE /users}: deleteUser(User)
        {PUT /users}: updateUser(User)
        {GET /users/{id}}: getUserById(String)
        {GET /users}: getUsers()
        {GET /users_static}: getUsersStaticList()
    2018-12-12 11:16:51.795 TRACE 11868 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping
        o.s.b.a.w.s.e.BasicErrorController:
        { /error}: error(HttpServletRequest)
        { /error, produces [text/html]}: errorHtml(HttpServletRequest,HttpServletResponse)
    

提交回复
热议问题