0

I'm trying to log all 400 and 500 error petition that throw the application.

I don't know if there is some way of doing.

The more equal that I found is /error petition who is class to define the format of all the exceptions raised in the backend but I don't know how to face it.

any suggestions?

I use spring-boot like framework. My error class look something like this :

@Controller
public class ErrorController extends AbstractErrorController
{
  public ErrorController(ErrorAttributes errorAttributes)
  {
   super(errorAttributes);
  }

 @RequestMapping(value = "/error", produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseBody
  public Map<String, Object> handleError(HttpServletRequest request)
 {
   Map<String, Object> errorAttributes = super.getErrorAttributes(request, false);
   return errorAttributes;
 }

 @Override
 public String getErrorPath()
 {
    return "/error";
  }
 }
Illidan
  • 149
  • 1
  • 8

1 Answers1

0

You probably need to disable the default error handler and page first, before adding your own, like excluding the default ErrorMvcAutoConfiguration class and or via app properties, check it out here: https://stackoverflow.com/a/58801298/6324746

rizesky
  • 424
  • 6
  • 13