简体   繁体   English

登录不打印方法名称

[英]logback not printing method name

using logback classic in java app but %M or %method prints a '?' 在Java应用程序中使用经典的logback,但%M或%method打印'?' 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 ? logback发出? 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 . 假设这是一个非生产型应用程序,请确保为%m的方法名称启用调试符号。

If you are using SMTP appender or ASYNC appender , then you should know about "includeCallerData" property. 如果使用的是SMTP附加程序ASYNC附加程序 ,则应该了解“ includeCallerData”属性。 This property is set to false because retrieving caller data is very expensive. 此属性设置为false,因为检索调用者数据非常昂贵。 Hence things like line number or method name are not retrieved by default. 因此,默认情况下不会检索行号或方法名称之类的内容。
In your case method name gets replaced by a CallerData.NA which is basically ? 在您的情况下,方法名称被CallerData.NA取代,基本上是

So, add this line to your logback.xml 因此,将此行添加到您的logback.xml

<includeCallerData>true</includeCallerData> <includeCallerData>真</ includeCallerData>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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