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

Logger$PrivateConfig.filter(Level, Marker, String) allocates empty varargs array

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.18.0
    • 2.18.1
    • Core
    • None

    Description

      While reviewing some JFR profiles, I notice significant allocations of Object[] due to use of some isEnabled conditions that ends up using empty varargs invoking org.apache.logging.log4j.core.Filter#filter(Logger, Level, Marker, String, Object...), for example the following call trace:

      at org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Level, Marker, String)
      at org.apache.logging.log4j.core.Logger.isEnabled(Level, Marker, String)
      

      We can avoid allocation on this hot path when invoking Filter#filter(Logger, Level, Marker, String, Object...) by reusing an empty object array for the varargs.

      Attachments

        Issue Links

          Activity

            People

              ckozak Carter Kozak
              schlosna David Schlosnagle
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: