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

DefaultLogEventBuilder causes incorrect location information to be logged

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 2.0.14
    • 2.0.0-alpha1
    • Core API
    • None

    Description

      See LOG4J2-2975. DefaultLogEventBuilder does

      	private void innerLog(LoggingEvent logggingEvent) {
      		if (logger instanceof LoggingEventAware) {
      			((LoggingEventAware) logger).log(logggingEvent);
      		} else {
      			logViaPublicLoggerAPI(logggingEvent);
      		}
      	}
      

      In both alternatives DefaultLogEventBuilder is going to show up as the caller of the logging API since there is no provision made to allow the implementation to determine the caller of the log method in DefaultEventBuilder.

      As such, for all practical purposes this class is useless. This issue does not affect Logback since it is using the NOPLoggingEventBuilder so the fluent API doesn't work in Logback at all. If it were using DefaultLogEventBuilder it would suffer from the same problem.

      The workaround is that any implementation that wants to support SLF4J's fluent API must implement its own LogEventBuilder.

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            rgoers@apache.org Ralph Goers
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: