Trying to get log4j2 section form values.yml using toYaml
but it does not retain the order.
log4j2.yml: |-
{{ toYaml .Values.log4j2 | indent 4 }}
output-
log4j2:
Configuration:
Appenders:
Console:
Filters:
DuplicateLogFilter:
ttlInSeconds: 60
MarkerFilter:
marker: TRACE
onMatch: ACCEPT
onMismatch: NEUTRAL
PatternLayout:
pattern: '%-5p | %d{yyyy-MM-dd HH:mm:ss,SSS} | [%t] [%X{AD.requestGUID}] [%X{trace.id}]
%x %c{1.}:%L - %m%n'
name: CONSOLE
target: SYSTEM_OUT
monitorInterval: 300
shutdownHook: disable
Expected output-
log4j2:
Configuration:
monitorInterval: 300
shutdownHook: disable
Appenders:
Console:
name: CONSOLE
target: SYSTEM_OUT
Filters:
MarkerFilter:
marker: TRACE
onMatch: ACCEPT
onMismatch: NEUTRAL
DuplicateLogFilter:
ttlInSeconds: 60
PatternLayout:
pattern: "%-5p | %d{yyyy-MM-dd HH:mm:ss,SSS} | [%t] [%X{AD.requestGUID}] [%X{trace.id}] %x %c{1.}:%L - %m%n"
Values files are parsed to a map (or dictionary if you will), and map structures in general are not required to preserve the field order. So your issue is not a problem of the toYaml
function as such, but of placing log4j configuration inside values.yaml
.
What you could do is moving your log4j configuration in to a separate log4j2.yml file (in the root of your chart), and including it as a raw file:
log4j2.yml: |-
{{- .Files.Get "log4j2.yml" | nindent 10 }}
(adjust the indent accordingly)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With