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

Message "ERROR Recursive call to appender" needs more diagnostic information.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.12.1
    • None
    • Core
    • None

    Description

      The class AppenderControl has logic that is intended to detect recursive calls to an appender.

       

      // code placeholder
          @PerformanceSensitive
          private boolean isRecursiveCall() {
              if (recursive.get() != null) {
                  appenderErrorHandlerMessage("Recursive call to appender ");
                  return true;
              }
              return false;
          }
      

      However, the logic behind this is flawed, leading to erroneous ERROR messages being printed on the console.

      In my use case, I have a log message being written,  utilizing the ParameterizedMessage APIs.   When log4j formats my message, it calls the toString method on the object being passed in.  If that toString() call results in another log message being written, log4j logs this error, which I believe to be erroneous.  Its not recursive... its just another log message that happens to be triggered by the construction of the first log message.  This wouldn't lead to a recursive loop.

      This should probably be implemented with a depth counter, and only error if it really does look recursive (deeper than 10 calls, or some such value).

      Also, the error logged should REALLY include a stack trace, so this isn't such a PITA to track down if someone really does have a recursive logging call.

       

      Attachments

        1. log4j2.xml
          0.4 kB
          Dan Armbrust
        2. Log4JRecurseTest.java
          0.8 kB
          Dan Armbrust

        Activity

          People

            rgoers Ralph Goers
            armbrust Dan Armbrust
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: