Camunda Logging

Default Configuration

In OMN Camunda Workflow Enginge we use Logback for Logging. By default a logback.xml is provided in /camunda/conf/logback.xml inside the OMN Camunda Docker Image:

<configuration scanPeriod="15 seconds" scan="true" debug="true">

    <property name="DEFAULT_LOG_PATTERN" value="%date [%thread] %-5level %logger{1} - %message%n"/>

    <include optional="true" file="/camunda/conf/logback_optional.xml" />

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${DEFAULT_LOG_PATTERN}</pattern>
        </encoder>
    </appender>

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>/camunda/logs/camunda.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>${DEFAULT_LOG_PATTERN}</pattern>
        </encoder>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>/camunda/logs/camunda.%i.log.zip</FileNamePattern>
            <MinIndex>1</MinIndex>
            <MaxIndex>10</MaxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>2MB</MaxFileSize>
        </triggeringPolicy>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </root>

    <logger name="org.camunda" level="INFO" additivity="false">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </logger>

    <logger name="de.apollon.omn.wfl" level="DEBUG" additivity="false">
        <appender-ref ref="FILE"/>
        <appender-ref ref="STDOUT"/>
    </logger>

</configuration>

Extend Default Configuration Via Optional Include File

In the default Logback XML above an entry point is provided for an optional logback_optional.xml file, which can be mounted to /camunda/conf/logback_optional.xml.

For example you can forward INFO level messages to another file via the following logback_optional.xml

<included>
    <appender name="FILE_OPT" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>/camunda/logs/camunda_opt.log</file>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>/camunda/logs/camunda_opt.%i.log.zip</FileNamePattern>
            <MinIndex>1</MinIndex>
            <MaxIndex>10</MaxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>2MB</MaxFileSize>
        </triggeringPolicy>
    </appender>
    <logger name="de.apollon.omn.wfl.ext">
        <appender-ref ref="FILE_OPT"/>
    </logger>
</included>

Limitations

Extending the configuration via the Include-File has its caveats and limitations:

Impact On Ancestor Loggers

If you set up a logger which is a child of a logger already defined in original logback.xml and has a lower log level than the ancestor logger, then this also affects the ancestor loggers.

For example if we would set up the logger "de.apollon.omn.wfl.ext" in the example above with a level of INFO directly on the logger like this:

...
    <logger name="de.apollon.omn.wfl.ext" level="INFO">
        <appender-ref ref="FILE_OPT"/>
    </logger>
...

Then also the FILE and STDOUT appender on the ancestor logger de.apollon.omn.wfl.ext in original logback.xml would only log INFO level messages from that package on downwards. That is why in our example we implicitly inherited DEBUG from the ancestor and used a ch.qos.logback.classic.filter.ThresholdFilter with INFO level on the appender.

...
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
...

Existing Loggers And Appenders Can Not Be Overwritten

Any Appenders or Loggers which are already defined in orginal logback.xml can not be overwritten.

This is due to the location where the logback_optional is actually included in logback.xml: It is included before the appender/logger declarations. So any declarations with the same name will be overwritten in main logback.xml.

Overwrite Default Configuration

To overcome the aforementioned limitations simply overwrite the original logback.xml by mounting a new one to /camunda/conf/logback.xml

Add a Loki Appender

By default the loki-logback-appender is available on the root classpath.

A Loki Appender could, for example, be configured by mounting the following XML to /camunda/conf/logback.xml

<configuration scanPeriod="15 seconds" scan="true" debug="true">

    <property name="DEFAULT_LOG_PATTERN" value="%date [%thread] %-5level %logger{1} - %message%n"/>

    <include optional="true" file="/camunda/conf/logback_optional.xml" />

    <appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
    <http class="com.github.loki4j.logback.ApacheHttpSender">
        <url>http://loki.omn.local:3100/loki/api/v1/push</url>
    </http>
    <format>
        <label>
            <pattern>app=CAMUNDA,host=${HOSTNAME},level=%level, omn_node=camunda</pattern>
        </label>
        <message>
            <pattern>h=${HOSTNAME} %date [%thread] %-5level %logger{1} - %message%n</pattern>
        </message>
    </format>
</appender>

    <root level="INFO">
        <appender-ref ref="LOKI"/>
    </root>

    <logger name="de.apollon.omn.wfl" level="DEBUG" additivity="false">
        <appender-ref ref="LOKI"/>
    </logger>

</configuration>

Welcome to the AI Chat!

Write a prompt to get started...