Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1527

TeeFilter prints stack traces of uncaught exceptions to the standard erorr stream

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 1.2.3
    • logback-access
    • None
    • Logback 1.2.3

      Spring boot webapp, with Logback configured to log to ConsoleAppender

    Description

      Problem

      In a webapp uncaught exceptions are handled (logged) by the servlet container (Tomcat in our case).

      However, Logback `TeeFilter` has the following code:

      try {
          // ... (omitted)
          filterChain.doFilter(teeRequest, teeResponse);
          // ... (omitted) 
      } catch (IOException e) {
          e.printStackTrace();
          throw e;
      } catch (ServletException e) {
          e.printStackTrace();
          throw e;
      }
      

      This causes the stack trace to appear twice in the console (once logged by TeeFilter, and once by Tomcat).

      Proposed solution

      1. Remove `e.printStackTrace();` statements from `TeeFilter` - it has no responsibility of printing stack traces of exceptions it can not handle
      2. Also replace `System.out.println` statements with logging to SLF4J API at INFO level

      I'd be happy to raise a PR for this if a new version of logback-access would be released soon after the fix.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            Rimsa Gediminas Rimsa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: