'Custom logging format for Keycloak running in Docker,

I want to change the log format for Keycloak running in a Docker container. The dockerfile looks like this:

version: "3.8"
services:
  keycloak:
      image: jboss/keycloak:15.0.0
      networks:
        keycloak_network:
      environment:
        DB_VENDOR: POSTGRES
        DB_PORT: 85435
        DB_ADDR: pg_keycloak
        DB_DATABASE: xxx
        DB_USER: xxx
        DB_SCHEMA: public
        DB_PASSWORD: xxx
        KEYCLOAK_USER: xxx
        KEYCLOAK_PASSWORD: xxx
        KEYCLOAK_IMPORT: /opt/jboss/keycloak/imports/my-realm.json
      ports:
        - 8080:8080
      depends_on:
        - pg_keycloak

The logging configuration is here by default: logging.configuration = file:/opt/jboss/keycloak/standalone/configuration/logging.properties

FYI: in the default logging.properties file are these lines, which I want to customize:

# Additional formatters to configure
formatters=PATTERN


formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n

formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{yyyy-MM-dd HH\:mm\:ss.SSS}|(keycloak)|%c (%t)| %s%e%n

How do I specify a custom logging.properties file, preferably in the dockercompose.yml file, so it uses the custom log format found within?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source