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

Expose StackTraceElement to public API

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I learned there are two features of log4j2 and its official Scala API that could work together to improve performance with some API changes.

      Log4j2's messages can include the source file name and line number by using a StackTraceElement.

      Scala macros can be used to provide compile time file names and line numbers to runtime for the cost of allocating a StackTraceElement. However, there is currently not a good way to combine the two.

      I created the changes we'd need to allow clients of log4j2 to manually provide StackTraceElement for a log message, and then I used the new methods to create StackTraceElement for Scala files at compile time. This will allow loggers to provide source location without having to create a stack trace.

       

      For log4j2 see https://github.com/shawjef3/logging-log4j2/commit/4f75053cdfe39614fc60ecc609f3658cdd4840db and for an example use by the scala loggers see https://github.com/shawjef3/logging-log4j-scala/commit/dd9a5dd2d6bef80ef4f0334c2ed7043299ddbad4.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                shawjef3 Jeff Shaw
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: