Spring Aop logging line number incorrect

后端 未结 1 710
不思量自难忘°
不思量自难忘° 2020-12-22 04:43

I am using spring aop to do logging for my application : I have before after and afterthrowing advice configured but the line numbers that I see is not of the target class b

相关标签:
1条回答
  • 2020-12-22 05:19

    I think this is not specifically a Spring AOP problem but just the way Log4j works, see Javadoc for PatternLayout:

    L

    Used to output the line number from where the logging request was issued.

    WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue.

    So my recommendation is to use a pattern layout without line number and use Spring AOP's capability of determining line numbers, roughly like this:

    joinPoint.getSourceLocation().getLine()
    
    0 讨论(0)
提交回复
热议问题