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

Method name does not print correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Bug
    • 2.13.3
    • None
    • Appenders
    • None
    • Windows 10, Java 1.8.0_251

    Description

      My log4j configuration has the following layout:

       

      <Property name="appenderPatternLayout">YF:%d{yyyy-MM-dd HH:mm:ss.SSS}:%5p (%c{1}:%M) - %m%n</Property>
      

       

       

      A log message was created by the method MIRunDashboardAction<T>.execute. The FQCN of the class was com.hof.mi.web.action.MIRunDashboardAction. The stack trace:

       

      StackLocator.calcLocation(String) line: 186
      
      StackLocatorUtil.calcLocation(String) line: 78
      
      LoggerConfig.log(String, String, Marker, Level, Message, Throwable) line: 409 
      
      AwaitCompletionReliabilityStrategy.log(Supplier<LoggerConfig>, String, String, Marker, Level, Message, Throwable) line: 63
      
      Logger.logMessage(String, Level, Marker, Message, Throwable) line: 153 
      
      Logger(Category).forcedLog(String, Priority, Object, Throwable) line: 388 
      
      Logger(Category).log(String, Priority, Object, Throwable) line: 499 
      
      YFAdvancedLogger.log(YFLogger$YFLogLevel, Object, Throwable, boolean) line: 39 
      
      YFAdvancedLogger(YFLogger).log(YFLogger$YFLogLevel, Object, Throwable) line: 145 
      
      YFAdvancedLogger(YFLogger).info(Object, Throwable) line: 113 
      
      YFAdvancedLogger(YFLogger).info(Object) line: 109 
      
      // Logger called from here
      MIRunDashboardAction<T>.execute(YFActionMapper<T>, HttpServletRequest, HttpServletResponse) line: 73 
      
      MIFormBindingController(FormBindingSpringController<T>).handleDefault(T, BindingResult, RedirectAttributes, HttpServletRequest, HttpServletResponse) line: 109 
      
      MIFormBindingController.handle(MIForm, BindingResult, RedirectAttributes, HttpServletRequest, HttpServletResponse) line: 57 

       

      However, the method printed in the log was one level lower than the actual one (see stack above).

      YF:2020-10-28 19:26:54.231: INFO (MIRunDashboardAction:handleDefault) - [42] [4E353F83] [/RunDashboard.i4] MIRunDashboardAction entered

       

       

      I think the bug is in line 187 of StackLocator.calcLocation().

       

      if (found && !fqcnOfLogger.equals(className)) {
          return stackTrace[i]; // Should this have been i-1 ?
      }
      

       

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            deepak.narayan Deepak Narayan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: