Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-493

Lambda expression call with log4j logs the wrong line number

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 2.0.0-alpha0, 2.0.0-alpha1
    • None
    • None
    • Any, with the latest (2.0.0-alpha1) version of SLF4J.

    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 against a Log4J backend. This causes potential confusion when a person debugging something is reading the logs as the line numbers are wrong!

      I know that it is SLF4J that is doing something wrong instead of Log4J, because running just with Log4J does not manifest the same behavior.

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

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

       

      Both of the programs run with a simple "./gradlew run" so it should be straightforward to reproduce.

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            danielthegray Daniel Gray
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: