[ 
https://issues.apache.org/jira/browse/LOG4J2-2953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17292590#comment-17292590
 ] 

Ralph Goers commented on LOG4J2-2953:
-------------------------------------

No. The logic in calcLocation is correct. The FQCN is the name of the class the 
application calls to perform logging. That class may call methods within 
itself. This logic is looking for the class that called the FQCN. So it walks 
the stack looking for the FQCN. It then skips all the stack entries in that 
class until it lands on an FQCN that is not that class. That is the one it will 
return.

> Method name does not print correctly
> ------------------------------------
>
>                 Key: LOG4J2-2953
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2953
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.13.3
>         Environment: Windows 10, Java 1.8.0_251
>            Reporter: Deepak Narayan
>            Priority: Minor
>
> My log4j configuration has the following layout:
>  
> {code:java}
> <Property name="appenderPatternLayout">YF:%d{yyyy-MM-dd HH:mm:ss.SSS}:%5p 
> (%c{1}:%M) - %m%n</Property>
> {code}
>  
>  
> A log message was created by the method 
> {color:#de350b}MIRunDashboardAction<T>.execute{color}. The FQCN of the class 
> was {color:#de350b}com.hof.mi.web.action.MIRunDashboardAction{color}. The 
> stack trace:
>  
> {noformat}
> 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 {noformat}
>  
> However, the method printed in the log was one level lower than the actual 
> one (see stack above).
> {noformat}
> YF:2020-10-28 19:26:54.231: INFO (MIRunDashboardAction:handleDefault) - [42] 
> [4E353F83] [/RunDashboard.i4] MIRunDashboardAction entered{noformat}
>  
>  
> I think the bug is in line 187 of StackLocator.calcLocation().
>  
> {code:java}
> if (found && !fqcnOfLogger.equals(className)) {
>     return stackTrace[i]; // Should this have been i-1 ?
> }
> {code}
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to