Skip to content

Commit cf977e0

Browse files
committed
feat(besu): add configurable json logging
1 parent 3ad607e commit cf977e0

5 files changed

Lines changed: 42 additions & 0 deletions

File tree

charts/network/charts/network-nodes/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ A Helm chart for Kubernetes
3030
| config.http.maxActiveConnections | int | `2000` | Maximum concurrent HTTP JSON-RPC connections. |
3131
| config.http.maxBatchSize | int | `512` | Maximum number of batched JSON-RPC calls per request. |
3232
| config.http.maxRequestContentLength | int | `524288000` | Maximum HTTP request body size in bytes. |
33+
| config.logFormat | string | `"plain"` | Log output format. Supports "plain" (default) or "json". |
3334
| config.logging | string | `"INFO"` | Log verbosity level for Besu components. |
3435
| config.metrics.categories | list | `["BLOCKCHAIN","ETHEREUM","EXECUTORS","JVM","NETWORK","PEERS","PROCESS","PRUNER","RPC","SYNCHRONIZER","TRANSACTION_POOL"]` | Metrics categories exposed to Prometheus. |
3536
| config.metrics.enabled | bool | `true` | Enable the Prometheus metrics endpoint. |

charts/network/charts/network-nodes/templates/configmap.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
{{- $persistenceEnabled := default false (get $persistence "enabled") }}
99
{{- $mountPath := default "" (get $persistence "mountPath") }}
1010
{{- $privateKeyFilename := default "privateKey" .Values.config.privateKeyFilename }}
11+
{{- $logFormat := default "plain" .Values.config.logFormat }}
1112
data:
1213
config.toml: |-
1314
data-path="/data"
@@ -61,3 +62,21 @@ data:
6162
metrics-host={{ .Values.config.metrics.host | quote }}
6263
metrics-port={{ .Values.service.ports.metrics | int }}
6364
metrics-category={{ .Values.config.metrics.categories | toJson }}
65+
{{- if eq $logFormat "json" }}
66+
log-config.xml: |-
67+
<?xml version="1.0" encoding="UTF-8"?>
68+
<Configuration status="INFO" monitorInterval="5">
69+
<Appenders>
70+
<Console name="Console" target="SYSTEM_OUT">
71+
<JsonLayout compact="false" eventEol="true" properties="true" stacktrace="true">
72+
<KeyValuePair key="container" value="${hostName}" />
73+
</JsonLayout>
74+
</Console>
75+
</Appenders>
76+
<Loggers>
77+
<Root level="${sys:root.log.level:-{{ .Values.config.logging }}}">
78+
<AppenderRef ref="Console" />
79+
</Root>
80+
</Loggers>
81+
</Configuration>
82+
{{- end }}

charts/network/charts/network-nodes/templates/statefulset-rpc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ spec:
7777
valueFrom:
7878
fieldRef:
7979
fieldPath: status.podIP
80+
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
81+
- name: LOG4J_CONFIGURATION_FILE
82+
value: /etc/besu/log-config.xml
83+
{{- end }}
8084
{{- with .Values.securityContext }}
8185
securityContext:
8286
{{- toYaml . | nindent 12 }}
@@ -133,6 +137,12 @@ spec:
133137
mountPath: /etc/besu/config.toml
134138
subPath: config.toml
135139
readOnly: true
140+
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
141+
- name: besu-config
142+
mountPath: /etc/besu/log-config.xml
143+
subPath: log-config.xml
144+
readOnly: true
145+
{{- end }}
136146
- name: besu-genesis
137147
mountPath: /etc/besu/genesis.json
138148
subPath: genesis.json

charts/network/charts/network-nodes/templates/statefulset-validator.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ spec:
7676
valueFrom:
7777
fieldRef:
7878
fieldPath: status.podIP
79+
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
80+
- name: LOG4J_CONFIGURATION_FILE
81+
value: /etc/besu/log-config.xml
82+
{{- end }}
7983
{{- with .Values.securityContext }}
8084
securityContext:
8185
{{- toYaml . | nindent 12 }}
@@ -132,6 +136,12 @@ spec:
132136
mountPath: /etc/besu/config.toml
133137
subPath: config.toml
134138
readOnly: true
139+
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
140+
- name: besu-config
141+
mountPath: /etc/besu/log-config.xml
142+
subPath: log-config.xml
143+
readOnly: true
144+
{{- end }}
135145
- name: besu-genesis
136146
mountPath: /etc/besu/genesis.json
137147
subPath: genesis.json

charts/network/charts/network-nodes/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ service:
8787
config:
8888
# -- (string) Log verbosity level for Besu components.
8989
logging: INFO
90+
# -- (string) Log output format. Supports "plain" (default) or "json".
91+
logFormat: plain
9092
# -- (string) Ledger storage backend (FOREST or BONSAI).
9193
dataStorageFormat: FOREST
9294
# -- (string) Filename containing each node's private key within mounted secrets.

0 commit comments

Comments
 (0)