title: Java Spring Boot not logging exceptions
body: <p>I have a spring boot rest service. When I send a request to the service, I would like to log whether or not it was a successful request or not. If the rest service is successfully, logger.info (any logger will be logged even logger.error) will be logged to the console. However, when an SQL exception is thrown, it does not log the logger.error portion to console. How do I get it so if an exception is thrown, it would also log that portion to the console? </p>
  
  <p>Here is the test method: </p>
  
  <pre><code>import org.slf4j.Logger;
  import org.slf4j.LoggerFactory   
  
  public String testMethod(){
      try{
  
          LOGGER.info("running test method");
  
          Class.forName("oracle.jdbc.driver.OracleDriver");
  
          Connection test = DriverManager.getConnection(
                  datasourceUrl,datasourceUsername,datasourcePassword);
          //Select data
          Statement stmt = test.createStatement();
  
          InputStream input = getClass().getResourceAsStream("/testMethodSQL.sql");
          String insertTableSQL = IOUtils.toString(input);
  
           PreparedStatement preparedStatement = prod.prepareStatement(insertTableSQL);
  
          ResultSet rs = preparedStatement.executeQuery();
  
          }
  
          test.close();
  
          LOGGER.info("test Method successfully ran");
  
          return "Done";
      }
      catch (Exception e) {
          e.printStackTrace();
          LOGGER.error("Error found: {}", e);
          return "An error occured: " +  e;
      }
  
  }
  </code></pre>
  
  <p>Here is my logback.xml file:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;appender name="Console" class="ch.qos.logback.core.ConsoleAppender"&gt;
      &lt;encoder class="net.logstash.logback.encoder.LogstashEncoder"&gt;
      &lt;/encoder&gt;
  &lt;/appender&gt;
  
  &lt;root level="info"&gt;
      &lt;appender-ref ref="Console" /&gt;
  &lt;/root&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>For example, when an exception is thrown the results would print out:</p>
  
  <pre><code>{"@timestamp":"2019-02-12T10:07:05.989-05:00","@version":1,"message":"running test method","logger_name":"com.test","thread_name":"http-nio-8080-exec-2","level":"INFO","level_value":20000,"RequestId":"6D71709D5A1A4C83876B68A661D696E3"}
  
  java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (TEST_TABLE.SYS_C0013283) violated
  </code></pre>
  
  <p>However, it does not log the Logger.error portion</p>