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

Avoid printing stack traces under certain conditions

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • logback-classic
    • None
    • Operating System: Windows
      Platform: PC

    • 97

    Description

      It would be useful if under certain very specific conditions, logback avoided printing stack traces.

      In particular, in server applications IOEXceptions are thrown under normal conditions, such as when the client closes its connection to the server.

      Typical code would look like:
      try

      { event = (AuditEvent) ois.readObject(); }

      catch (java.io.EOFException e)

      { logger.info("Caught java.io.EOFException closing connection.", e); break; }

      catch (IOException e)

      { logger.info("Caught java.io.IOException: ", e); break; }

      catch (ClassNotFoundException e)

      { logger.error("Unexpected ClassNotFoundException.", e); writeResponse(e); break; }

      Most of the time we would like to avoid printing the stack trace for the two exceptions but not the third.

      Possible solution:

      Marker ignoreST = MarkerFactgory.getMarker("IGNORE_STACK_TRACE");
      logger.info(ignoreST, "Caught java.io.EOFException closing connection.", e);

      Note that even if most of the time we would like to avoid printing the stack trace, it should still be possible to allow st printing by overriding some parameter.

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            ceki Ceki Gülcü
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: