0

For a simple Spring Boot app with Spring Security, I want to trigger a RequestRejectedException and see it in my console output. I think I'm able to trigger a runtime expection of this type, but no ERROR logging appears in my console.

What I've done...

I've created a simple Spring Boot app (via start.spring.io) with Spring Web and Spring Security dependencies.

I've added a simple controller:

@RestController
@RequestMapping("/api/test/")
public class MyController {

    @GetMapping("/get") 
    public String getString() {
        return "hello";
    }
    
}

Within Spring Tool Suite it runs on port 8080.

Console output shows it starts up correctly.

Spring Security generates the local development security password.

I can login using the generated password and 'User' and hit this URL http://localhost:8080/api/test/get which returns the hello String.

I then create a RequestRejectedException (runtime exception) by adding a semi-colon to the end of the URL. The browser returns this type of ERROR: There was an unexpected error (type=Bad Request, status=400).

I don't see anything in my CONSOLE output (or logs if I configure logback to print to file). I was expecting to see something like this:

org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL contained a potentially malicious String ....

Does anyone know why I can't see the RequestRejectedException in my CONSOLE/logs?

Thanks.

EHammond
  • 23
  • 4
  • I am seeing other exceptions. e.g if I add a divide by zero statement, an ArithmeticException is printed in the console – EHammond May 18 '23 at 08:57
  • *SOLVED* RequesteRejectedException isn't ERROR. It's DEBUG. Add logging.level.root=debug to application.properties to see the request rejected exception. – EHammond May 18 '23 at 09:25
  • I don't know what mechanism makes one exception (ArithmeticException) an ERROR and another exception (RequestRejectedException) DEBUG. – EHammond May 18 '23 at 09:27

0 Answers0