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

SLF4J fluent API fails to capture call site location due to missing LoggingEventAware implementation

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.13.3
    • 2.19.0
    • SLF4J Bridge
    • None

    Description

      The logger outputs the wrong log line (120 for INFO, 117 for DEBUG, etc.) instead of the line in the program that generated the log, when running with the slf4j bridge. This causes potential confusion when a person debugging something is reading the logs as the line numbers are wrong!

      I have prepared 2 simple CLI apps to show the correct behavior (with only Log4J) and the incorrect behavior (with the SLF4J bridge). Both are using the exact same configuration (log4j2.properties). The repositories of these sample projects are:

      Good behavior with a pure log4j:
      https://github.com/danielthegray/log4j-nobugsample
      Wrong behavior with the slf4j bridge:
      https://github.com/danielthegray/slf4j-bugsample

      Attachments

        Issue Links

          Activity

            People

              pkarwasz Piotr Karwasz
              daniel.gray Daniel Gray
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: