Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2365

NameAbbreviator skips first fragments

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.11.0, 2.11.1
    • 3.0.0, 2.11.2
    • Pattern Converters
    • None

    Description

      When I use LoggernPatternConverter in beginning of my layout it outputs as expected

      <PatternLayout pattern="%c{1.1.*} %date{HH:mm:ss.SSS} %-5level %-25thread| %msg%n%xThrowable"/>
      c.k.zoo.CuratorEnsembleProvider 16:48:13.175 INFO main | Connecting to ensemble on [localhost]:8080

       However when I move converter to the end of the layout it stops abbreviating logger name parts.

      <PatternLayout pattern="%date{HH:mm:ss.SSS} %-5level %-25thread| %c{1.1.*} %msg%n%xThrowable"/>
      16:47:38.687 INFO main | com.kamagames.zoo.CuratorEnsembleProvider Connecting to ensemble on [localhost]:8080

       

      I believe it's caused by code in NameAbbreviator which stops processing first pattern fragments when abbreviated string length is larger than current position in StringBuilder

       

      for (int i = 0; i < fragments.length - 1 && pos < original.length(); i++) {
       pos = fragments[i].abbreviate(sb, pos);
      } 

       

      Attachments

        Issue Links

          Activity

            People

              ckozak Carter Kozak
              undefz Eugene Zimichev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: