简体   繁体   中英

logback not printing method name

using logback classic in java app but %M or %method prints a '?' instead of method name. anyone has an idea ? here is the pattern

%d{yyyy-MM-dd HH:mm:ss.SSS} %level %thread %mdc{X-CorrelationId} %logger %method - %msg%n

logback emits ? instead of the method name only when the method name could not be determined . Assuming this is a non-production app, make sure to enable debug symbols for the method name to appear for %m .

If you are using or , then you should know about property. ,则应该了解属性。 This property is set to false because retrieving caller data is very expensive. Hence things like line number or method name are not retrieved by default.
In your case method name gets replaced by a which is basically 取代,基本上是

So, add this line to your logback.xml

<includeCallerData>true</includeCallerData>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM