Skip to main content

The most recent patch for this version is 2.1.1.  Learn more  

Version: 2.1

Logback samples

This is a set of examples of logback sample files used for customizing your logging configuration. The logback logging system is used by Spring Boot. Read the Logback section to learn how Access Decision Service (ADS) utilizes Logback.

logbackAdmin.xml

For enabling the audit events and logging only the administrative events:

<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<property name="ADMIN_LOG_FILE" value="./logs/ads-admin-event.log"/>
<appender name="ADMIN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp><fieldName>timestamp</fieldName></timestamp>
<version/>
<loggerName/>
<threadName/>
<logLevel/>
<!-- custom provider -->
<provider class="com.axiomatics.ads.util.CustomRawMessageJsonProvider">
<fieldName>message</fieldName>
</provider>
</providers>
</encoder>
<file>${ADMIN_LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${ADMIN_LOG_FILE}.%d{yyyy-MM-dd}.%i.log.gz}</fileNamePattern>
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
</rollingPolicy>
</appender>
<root>
<appender-ref ref="CONSOLE"/>
</root>
<logger name="com.axiomatics.audit.ads.admin" additivity="true">
<appender-ref ref="ADMIN_FILE"/>
</logger>
</configuration>
note

The custom provider class is required for concise_json and verbose_json modes. If you're generating logs in XML format, you can simplify Logback to use any standard mechanism and remove the custom provider.

Logback and tracing information

If tracing is enabled (as detailed in the Tracing section), either through OpenTelemetry or other agents, you can include tracing context like span_id or trace_id in your logs. This is achieved by specifying the <mdc/> field within the <providers> section, as shown in the example below:

<providers>
<timestamp><fieldName>timestamp</fieldName></timestamp>
<version/>
<loggerName/>
<threadName/>
<logLevel/>
<mdc>
<includeMdcKeyName>trace_id</includeMdcKeyName>
</mdc>
...
</providers>
...