Override the Default logback.xml with the HiveMQ Platform Operator
Starting from version 1.6.0, it is possible to override the logback.xml via config.customLogbackConfig
parameter. Link: HiveMQ Platform Operator for Kubernetes 1.6.0
The article refers to helm-charts/charts/hivemq-platform at master · hivemq/helm-charts (HiveMQ Platform) version:
NAME CHART VERSION APP VERSION DESCRIPTION
hivemq/hivemq-platform 0.2.18 4.30.0 HiveMQ Platform Helm Chart (new)
The article explains how to deliver a customized logback.xml
to the HiveMQ Platform containers.
Instructions
Prepare the logback.xml and test it locally first.
Create a configMap
logback-configuration
from the custom logback.xml configuration file:kubectl delete configMap logback-configuration --namespace hivemq
kubectl create configMap logback-configuration --from-file logback.xml --namespace hivemq
Override the default HiveMQ Logback folder by adding the element to the env array in the hivemq-platform’s values.yaml. The default Logback folder is
/opt/hivemq/conf
and the following example will override the default value with/opt/hivemq/logback-my-configuration
:Add the element to the additionalVolumes array in the hivemq-platform’s values.yaml:
Execute the helm upgrade command to pick up the changes:
If everything is correct the rolling restart will happen.
End-to-end test
Updating the logback.xml configuration file
In order to test end-to-end it is necessary first to apply the custom logback.xml configuration and then make sure it is applied. For example, it is possible to add a test log file to the logback configuration, which name differs from the standard log filenames. Then, if, after applying the new logback configuration the test log file exists, it proves that the new logback configuration is working. If the test log file does not exist, it denies that the new logback configuration is working. To add a test log file it is necessary to append the following to the logback.xml:
Note that everything is a copy of the hivemq.log configuration except of the test log file name, which is hivemqXXX.log instead of the usual hivemq.log.
In order to write the actual data to the log you need to update the following section in the logback.xml:
This will write the hivemq log not only into the default FILE but also into the test log FILE2.
The example logback.xml is attached hereby:
Create a configMap
logback-configuration
from the custom logback.xml configuration file:Override the default HiveMQ Logback folder by adding the element to the env array in the hivemq-platform’s values.yaml. The default Logback folder is
/opt/hivemq/conf
and the following example will override the default value with/opt/hivemq/logback-my-configuration
:Edit the values.yaml, add a new element to the additionalVolumes array in the hivemq-platform’s values.yaml:
Execute the helm upgrade command to pick up the changes:
Check the container for the test log file:
If there is the test log file, the filename hivemqXXX.log will be present and it means that the override is working:
If the hivemqXXX.log is absent, it means that the override is not working.