Skip to content

feat: allow configurable json logging for besu#12

Merged
roderik merged 3 commits intomainfrom
feat/besu-log-format
Sep 17, 2025
Merged

feat: allow configurable json logging for besu#12
roderik merged 3 commits intomainfrom
feat/besu-log-format

Conversation

@roderik
Copy link
Copy Markdown
Member

@roderik roderik commented Sep 17, 2025

Summary

  • add a logFormat toggle for Besu nodes supporting plain or json output
  • generate a Log4j2 JSON layout configmap and wire LOG4J env + mount when selected
  • document the new option in the network-nodes chart values

Testing

  • bun run typecheck
  • bun run check
  • bun run test
  • helm template charts/network
  • helm template charts/network --set network-nodes.config.logFormat=json

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:

  • Support configurable logFormat in network-nodes chart to toggle between plain and JSON output
  • Generate and conditionally mount a Log4j2 JSON layout configuration and set LOG4J_CONFIGURATION_FILE env var when JSON logging is enabled
  • Document the logFormat option in values.yaml and README

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 logFormat option 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 logFormat is set to "json".
  • Helm Chart Integration: Updates the network-nodes Helm 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 logFormat option is documented in the README.md for the network-nodes chart, 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

  1. 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.

@github-actions github-actions Bot added the qa:running QA workflow is currently running label Sep 17, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 17, 2025

To view in Slack, search for: 1758126535.424919

@github-actions github-actions Bot added the status:ready-for-review Pull request is ready for review label Sep 17, 2025
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions github-actions Bot added qa:success QA workflow passed successfully and removed qa:running QA workflow is currently running labels Sep 17, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 logFormat option in the network-nodes Helm chart, allowing users to switch between plain (default) and json logging for Besu nodes.
  • Log4j2 JSON Configuration: When json log 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_FILE environment variable is conditionally set to point to the generated log-config.xml and the file is mounted into the Besu pods (both RPC and Validator statefulsets).
  • Documentation Update: The new logFormat option has been documented in the network-nodes chart's values.yaml and README.md files.
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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +80 to +83
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
- name: LOG4J_CONFIGURATION_FILE
value: /etc/besu/log-config.xml
{{- end }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Comment on lines +79 to +82
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
- name: LOG4J_CONFIGURATION_FILE
value: /etc/besu/log-config.xml
{{- end }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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" }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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" }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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" }}.

@roderik roderik force-pushed the feat/besu-log-format branch from cf977e0 to 7dde86c Compare September 17, 2025 16:37
@github-actions github-actions Bot added qa:running QA workflow is currently running qa:success QA workflow passed successfully and removed qa:success QA workflow passed successfully qa:running QA workflow is currently running labels Sep 17, 2025
@roderik roderik force-pushed the feat/besu-log-format branch from 7dde86c to ba3e03b Compare September 17, 2025 16:39
@github-actions github-actions Bot added qa:running QA workflow is currently running qa:success QA workflow passed successfully feat New feature and removed qa:success QA workflow passed successfully qa:running QA workflow is currently running labels Sep 17, 2025
* origin/main:
  feat: support external artifact sourcing (#9)

# Conflicts:
#	charts/network/charts/network-nodes/templates/_helpers.tpl
@github-actions github-actions Bot added qa:running QA workflow is currently running qa:success QA workflow passed successfully and removed qa:success QA workflow passed successfully qa:running QA workflow is currently running labels Sep 17, 2025
@github-actions github-actions Bot added qa:running QA workflow is currently running and removed qa:success QA workflow passed successfully labels Sep 17, 2025
@github-actions github-actions Bot added qa:success QA workflow passed successfully and removed qa:running QA workflow is currently running labels Sep 17, 2025
@roderik roderik merged commit b0abb43 into main Sep 17, 2025
7 checks passed
@roderik roderik deleted the feat/besu-log-format branch September 17, 2025 17:08
@github-actions github-actions Bot added status:merged Pull request has been merged and removed status:ready-for-review Pull request is ready for review labels Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature qa:success QA workflow passed successfully status:merged Pull request has been merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant