Java Agent logs how to get %file %line %method

New Contributor

Java SpringBoot application V: 2.5.4

applicationsInsightsAgent V:3.2.0


The log pattern that I am using for the application looks something like:

mdcPattern=%replace(accountId:%X{accountId} webUserId:%X{webUserId} payload:%X{payload}){'(^| )?[a-zA-Z]+:( |$)', ''}
logPatternConsole=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level ${PID} ---[${mdcPattern}] [%logger{0} %file:%line->%method] : %msg %n


which produces console outputs like

2021-11-09 16:44:47 [https-jsse-nio-8080-exec-4] DEBUG 50483 ---[] [ApiController>greetings] : [***] 


The logging in the azure logging workspace picks up under "properties" values such as

LoggerName: com.mia.wa.controller.ApiController
LoggingLevel: DEBUG
SourceType: Logger


and when upgrading from V: 3.1.1 to 3.2.0 it also picked up ThreadName



The problem is that the values specified in the log pattern which are dynamic and show per log output on the console, the file name, the line number and the name of the method 


is not capture in the Azure Logs AppTrace


 Is there anyway to have those values sent back to the Azure Logs and show as properties (the same way that the ThreadName now shows or even the MDC values )








0 Replies