Logging both Camunda and Tomcat logs to Azure App Insights

Hello,

I’m having hard time configuring Camunda and Tomcat logging. I hope someone will be able to help me.

My objective is to write both Camunda and Tomcat logs to Azure App Insights.
There is no JUL Handler for App Insights however there is such Logback appender - applicationinsights-logging-logback-2.6.0.jar

I have vanilla Camunda 7.12 running inside Tomcat 9.0.24.
According to https://docs.camunda.org/manual/7.12/user-guide/logging/ Camunda is by default using slf4j and Java Util Logging.

Having slf4j in place, replacing JUL with Logback seemed to be straight forward taks.

  1. I deleted slf4j-jdk14-1.7.26.jar from ${catalina.base}/lib dir.
  2. I added logback-core-1.2.3.jar, logback-classic-1.2.3.jar, applicationinsights-logging-logback-2.6.0.jar and applicationinsights-core-2.6.0.jar
    to ${catalina.base}/lib dir
  3. I added logback.xml also to lib folder
<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{10} - %msg%n</pattern>
    </encoder>
  </appender>
  <appender name="FILE-CAMUNDA" class="ch.qos.logback.core.FileAppender">
    <file>${catalina.base}/logs/camunda-logback.log</file>
    <encoder><pattern>%-4relative [%thread] %-5level %logger{100} - %msg%n</pattern></encoder>
  </appender>
  <appender name="FILE-CATALINA" class="ch.qos.logback.core.FileAppender">
    <file>${catalina.base}/logs/catalina-logback.log</file>
    <encoder><pattern>%-4relative [%thread] %-5level %logger{100} - %msg%n</pattern></encoder>
  </appender>
  <appender name="aiAppender" class="com.microsoft.applicationinsights.logback.ApplicationInsightsAppender">
    <instrumentationKey>${INSIGHTS_KEY}</instrumentationKey>
  </appender>
  
  <logger name="org.camunda" level="info"><appender-ref ref="FILE-CAMUNDA" /><appender-ref ref="aiAppender" /></logger>
  <logger name="org.apache.catalina" level="info"><appender-ref ref="FILE-CATALINA" /><appender-ref ref="aiAppender" /></logger>

  <root level="info">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

This configuration worked only partialy, i.e.:

  • Camunda logs were successfully written to file and App Insights
  • Tomcat logs weren’t send to Insinghts nor to file configured in logback.xml
  • Tomcat logs were written to ${catalina.base}/logs/catalina.log as if JUL was still effective

I read somewhere that deletion of logging.properties should disable JUL but only effect I noticed was that Tomcat logging level shifted to debug.

Then I tried to reconfigure Tomcat using https://github.com/tomcat-slf4j-logback/tomcat-slf4j-logback
Effect was opposite i.e. Tomcat logs were written with Logback but Camunda log file was left empty (I tried both org.apache.juli.logging.ch.qos.logback.core.FileAppender and org.apache.juli.logging.ch.qos.logback.core.rolling.RollingFileAppender).

Then since Tomcat uses web app specific class loaders before common class loaders I tried to copy logback jar’s and xml file to ${catalina.base}\webapps\camunda but again only empty log file was created.

In all described scenarios I didn’t noticed any suspicious entries on console.
I spent two working days on this issue and I’m running out of ideas what else I could try.
I’ll appreciate any help.

Kind Regards
Jarek

Hello Jarek,
now you can run application insights v3 as java agent. I was able to set it up using Azure Monitor Application Insights Java - Azure Monitor | Microsoft Docs.

All the best.
Petr