feat: allow configurable json logging for besu#12
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @roderik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request enhances the network-nodes Helm chart by adding support for configurable JSON logging for Besu nodes. This feature allows users to easily switch their Besu node logs from the default plain text format to a structured JSON format, which is highly beneficial for centralized log management systems and automated log analysis.
Highlights
- Configurable JSON Logging: Introduced a new
logFormatoption in the Helm chart to switch Besu node logging between "plain" (default) and "json" formats. - Log4j2 JSON Configuration: Dynamically generates a Log4j2 XML configuration for JSON output, which is activated when the
logFormatis set to "json". - Helm Chart Integration: Updates the
network-nodesHelm chart to wire the Log4j2 configuration and mount it for both Besu RPC and Validator nodes when JSON logging is enabled. - Documentation Update: The new
logFormatoption is documented in theREADME.mdfor thenetwork-nodeschart, providing clear instructions for its use.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
|
To view in Slack, search for: 1758126535.424919 |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Remember to bump the version in charts/network/charts/network-nodes/Chart.yaml so that Helm picks up the new logFormat feature.
- The conditional LOG4J env var and volumeMount blocks are duplicated in both statefulset templates—consider extracting them into a shared helper to DRY up the code.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remember to bump the version in charts/network/charts/network-nodes/Chart.yaml so that Helm picks up the new logFormat feature.
- The conditional LOG4J env var and volumeMount blocks are duplicated in both statefulset templates—consider extracting them into a shared helper to DRY up the code.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Summary of Changes
Hello @roderik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request enhances the network-nodes Helm chart by adding support for configurable log output formats for Besu nodes. Users can now choose to have their Besu logs generated in a structured JSON format, which significantly improves the ease of parsing, filtering, and analyzing logs with external tools, compared to the traditional plain text output. This change provides greater flexibility for log management and observability within Besu deployments.
Highlights
- Configurable Log Format: Introduced a new
logFormatoption in thenetwork-nodesHelm chart, allowing users to switch betweenplain(default) andjsonlogging for Besu nodes. - Log4j2 JSON Configuration: When
jsonlog format is selected, a Log4j2 JSON layout configuration (log-config.xml) is dynamically generated and included in the ConfigMap. - Environment Variable and Volume Mount: The
LOG4J_CONFIGURATION_FILEenvironment variable is conditionally set to point to the generatedlog-config.xmland the file is mounted into the Besu pods (both RPC and Validator statefulsets). - Documentation Update: The new
logFormatoption has been documented in thenetwork-nodeschart'svalues.yamlandREADME.mdfiles.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable logging format for Besu nodes, allowing either 'plain' text or 'json' output. The changes are well-implemented by adding a new value in the Helm chart, conditionally generating a Log4j2 configuration in a ConfigMap, and mounting it into the Besu pods. My feedback focuses on improving code maintainability by reducing duplication in the StatefulSet templates.
| {{- if eq (default "plain" .Values.config.logFormat) "json" }} | ||
| - name: LOG4J_CONFIGURATION_FILE | ||
| value: /etc/besu/log-config.xml | ||
| {{- end }} |
There was a problem hiding this comment.
To improve maintainability and avoid repetition, this condition eq (default "plain" .Values.config.logFormat) "json" should be extracted into a variable at a higher scope (e.g., at the top of the file). This condition is also used for the volumeMounts section later in this file.
You could define a variable like {{- $jsonLoggingEnabled := eq (default "plain" .Values.config.logFormat) "json" }} and then use {{- if $jsonLoggingEnabled }} in both places.
| {{- if eq (default "plain" .Values.config.logFormat) "json" }} | ||
| - name: LOG4J_CONFIGURATION_FILE | ||
| value: /etc/besu/log-config.xml | ||
| {{- end }} |
There was a problem hiding this comment.
To improve maintainability and avoid repetition, this condition eq (default "plain" .Values.config.logFormat) "json" should be extracted into a variable at a higher scope (e.g., at the top of the file). This condition is also used for the volumeMounts section later in this file.
You could define a variable like {{- $jsonLoggingEnabled := eq (default "plain" .Values.config.logFormat) "json" }} and then use {{- if $jsonLoggingEnabled }} in both places.
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable logFormat option for Besu nodes, allowing users to switch between plain text and json log output. The implementation correctly adds a new value to the Helm chart, updates the documentation, and conditionally generates and mounts a Log4j2 configuration for JSON logging. My review includes a few suggestions to improve the Log4j2 configuration for production environments and to enhance the maintainability of the Helm templates by reducing code repetition. Overall, this is a valuable feature addition.
| {{- if eq $logFormat "json" }} | ||
| log-config.xml: |- | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Configuration status="INFO" monitorInterval="5"> |
There was a problem hiding this comment.
The Log4j2 configuration has status="INFO". This will cause Log4j2 to print its internal status logging at the INFO level to standard output, which can be verbose. It's generally recommended to set this to WARN in production environments to only see important internal Log4j2 messages.
<Configuration status="WARN" monitorInterval="5">| <Configuration status="INFO" monitorInterval="5"> | ||
| <Appenders> | ||
| <Console name="Console" target="SYSTEM_OUT"> | ||
| <JsonLayout compact="false" eventEol="true" properties="true" stacktrace="true"> |
There was a problem hiding this comment.
The JsonLayout is configured with compact="false", which produces multi-line, pretty-printed JSON logs. While this is human-readable, most log processing systems work best with compact, single-line JSON objects per log event. Using compact="true" is generally better for log aggregation and parsing.
<JsonLayout compact="true" eventEol="true" properties="true" stacktrace="true">| valueFrom: | ||
| fieldRef: | ||
| fieldPath: status.podIP | ||
| {{- if eq (default "plain" .Values.config.logFormat) "json" }} |
There was a problem hiding this comment.
The expression (default "plain" .Values.config.logFormat) is used multiple times in this file (here and for the volumeMount). To improve readability and maintainability by following the DRY principle, consider defining a variable at the top of the file and reusing it. For example: {{- $logFormat := default "plain" .Values.config.logFormat -}} and then use {{- if eq $logFormat "json" }}.
| valueFrom: | ||
| fieldRef: | ||
| fieldPath: status.podIP | ||
| {{- if eq (default "plain" .Values.config.logFormat) "json" }} |
There was a problem hiding this comment.
The expression (default "plain" .Values.config.logFormat) is used multiple times in this file (here and for the volumeMount). To improve readability and maintainability by following the DRY principle, consider defining a variable at the top of the file and reusing it. For example: {{- $logFormat := default "plain" .Values.config.logFormat -}} and then use {{- if eq $logFormat "json" }}.
cf977e0 to
7dde86c
Compare
7dde86c to
ba3e03b
Compare
* origin/main: feat: support external artifact sourcing (#9) # Conflicts: # charts/network/charts/network-nodes/templates/_helpers.tpl
Summary
Testing
Summary by Sourcery
Add a logFormat toggle to the network-nodes Helm chart to enable JSON logging for Besu nodes by generating a Log4j2 JSON layout configmap, mounting it in the pods, and updating documentation
New Features: