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

%n is necessary to separate real message from exception stack trace

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 0.9.26
    • logback-classic
    • None

    Description

      I started using the SMTPAppender and defined this pattern layout:
      <Pattern>Zeitstempel: %date%(%n)Kontext: %contextName%(%n)Angeforderte URI: %X

      {req.requestURI}

      %(%n)QueryString: %X

      {req.queryString}

      %(%n)Nachricht: %msg</Pattern>

      I do receive single log messages only so I don't need a %n at the end. Unfortunately, my log messages are messed up.
      Instead of:
      Nachricht: <msg>
      <ex>

      as the default log layout, I get:
      Nachricht: <msg><ex>

      I added a %n and it solved the problem. I was able to reproduce this with the FileAppender but this behavior make no sense. The exception is part of the message and should always include a \n internally unless a %ex is exlicitly defined. The last %n includes two line feed at once.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            michael-o Michael Osipov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: