This is in a Gradle project using Groovy for the app code as well as test code. But I'm using a logback.xml file for configuration.
One factor here that may be significant is that I am using the Groovy @Slf4j annotation to provide a logger.
The %method
and %line
conversion words usually get printed out as "invoke" and "-1" respectively (although sometimes "invoke0" with "-2").
Interestingly, it does sometimes print the method and number: for example when it's an ERROR
level log with an Exception
parameter:
log.error( 'indexSearcher.indexReader.close() threw Exception', e )
... I presume that's something to do with the e
object carrying with it "location" data which logback can then exploit. But just occasionally an INFO
level message gets printed with the method and line number: it's quite puzzling.
I've seen people having problems with an async appender, but my appender is ROLLING_FILE (RollingFileAppender). This is not an extension of an async appender.
I've tried other remedies documented in other SO questions (e.g. here): I've added these lines to my appender:
<includeCallerData>true</includeCallerData>
<param name="locationInfo" value="true" />
... did not solve the problem.
Someone somewhere said that it was necessary to ensure debug data was switched on at some point. In a Groovy context I'm not sure how I might try that idea.