title: Spring Boot REST CustomException using ControllerAdvice Not Showing in logs or stdout
body: <p>In a project which uses Java 1.8, lombok and Spring Boot 2.1.5.RELEASE, created a custom exception which is not showing up anywhere in my logs files or stdout.</p>
  
  <hr>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.5.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt;
  &lt;/parent&gt;
  
  &lt;dependencies&gt;
     &lt;dependency&gt;
         &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
         &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
     &lt;/dependency&gt;
     &lt;dependency&gt;
         &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
         &lt;artifactId&gt;lombok&lt;/artifactId&gt;
         &lt;optional&gt;true&lt;/optional&gt;
     &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <hr>
  
  <p>RestController:</p>
  
  <pre><code>@Slf4j
  @RestController
  @RequestMapping("/products")
  public class RestController {
  
      private HttpHeaders headers = null;
  
      @Autowired
      ProductDao productDao;
  
      public RestController() {
          headers = new HttpHeaders();
          headers.add("Content-Type", "application/json");
      }
  
      @RequestMapping(value = {"/{id}"}, 
                      method = RequestMethod.GET, 
                      produces = "APPLICATION/JSON")
      public ResponseEntity&lt;Object&gt; getProductByUsingId(@PathVariable(value = "id", required = true) Integer id) 
      throws IOException, ProductNotFoundException {
  
          if (null == id) {
              return new ResponseEntity&lt;Object&gt;(HttpStatus.NOT_FOUND);
          }
  
          ProductResponse product = productDao.findProductById(id);
  
          if (null == product) {
              return new ResponseEntity&lt;Object&gt;(HttpStatus.NOT_FOUND);
          }
          return new ResponseEntity&lt;Object&gt;(product, headers, HttpStatus.OK);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>ProductNotFoundException:</p>
  
  <pre><code>import org.springframework.http.HttpStatus;
  import org.springframework.web.bind.annotation.ResponseStatus;
  
  @ResponseStatus(value=HttpStatus.NOT_FOUND, reason="Product Not Found")
  public class ProductNotFoundException extends Exception {
  
      private static final long serialVersionId = 1L;
  
      public ProductNotFoundException(int id) {
          super("Product does not exist with id: " + id);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>ControllerAdvice:</p>
  
  <pre><code>@Slf4j
  @ControllerAdvice(annotations = RestController.class)
  public class ProductControllerAdvice {
  
      @ExceptionHandler(ProductNotFoundException.class)
      @ResponseStatus(value= HttpStatus.NOT_FOUND)
      public void handleProductNotFoundException() {
          log.error("\n\n\tProductNotFoundException handler executed\n");
      }
  }
  </code></pre>
  
  <p>When I hit my REST Endpoint:</p>
  
  <pre><code>http://localhost:8080/products/0
  </code></pre>
  
  <p>It returns an HTTP 404 - which it should.</p>
  
  <p>But I don't see the ERROR anywhere in my logs.log (using <code>grep -rnw logs.log -e 'ERROR'</code>) file and/or inside stdout?</p>
  
  <p>Also, tried having <code>ProductNotException extend RuntimeException</code>, and it still didn't work...</p>
  
  <p>What am I possibly doing wrong?</p>